MATLAB: Input-Output Fitting problem with a Neural Network – Stock predication

fitnetnnstarttrain

Hi, I'm trying to predict stock values(in this case, the closing value). In the end I want to achieve the same result as this example, Example
I use Apples historical data over a year( historical data )
I will use the "close price" and its corresponding date, but I cannot figure out how to use "input" and "target" and what they mean.
% This script assumes these variables are defined:
x = simplefitInput; //
t = simplefitTargets;
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
% View the Network
%view(net)
If understand it correctly, x is the input of the system. But what is t ? So Im wondering: What kind of values do I give to x and t ?

Best Answer

close all, clear all, clc, plt = 0
% NOTE: SOME SEMICOLONS REMOVED FOR DISPLAY PURPOSES
% Read Useful Info
% help nndatasets
% doc nndatasets
% x is the input
% t is the training target for the output
% y is the output
% e is the error (e=t-y)
% Data Selection
[ x ,t ] = simplefit_dataset;
whos
[I N ] = size(x) %[ 1 94 ]

[O N ] = size(t) %[ 1 94 ]
%Read more Useful Info
% help simplefit_dataset
% doc simplefit_dataset
plt = plt+1, figure(plt)
plot(x,t,'LineWidth',2)
MSE00 = var(t',1) % 8.3378 MSE Reference
% Using as many defaults as is reasonable:
net = fitnet; % net = net will reveal all defaults
[ net tr y e] = train(net,x); % tr = tr will reveal training details
% y = net(x);
% e = t - y
MSE = mse(e) % 4.9880e-008 Mean-squared-error
NMSE = MSE/MSE00 % 5.9824e-009 Normalized
% Coefficient of determination, Rsquared, is interpreted as the fraction of target variance that is modeled by the net. See Wikipedia for a decent discussion
R2 = 1-NMSE % 1.0000 Almost Perfect!
%See the training record,tr, for details of the default data division into training, validation and test subsets and training details
tr = tr
Hope this helps.
Thank you for formally accepting my answer
Greg