%% Script function: Example of time series prediction using a lag matrix % Build the sample data set: t=linspace(0,4*pi,200); y=sin(t); X=lag(y,4,1); [dim,numpts]=size(X); PtoKeep=10; %Approximate percent of the data to use for the model PtsTrain=ceil((PtoKeep/100)*numpts); %Number of points to use for training PtsTest=numpts-PtsTrain; %Number of points to use for testing tempidx=randperm(numpts); %Randomize the order of the data going in Patterns=X(1:4,tempidx(1:PtsTrain)); % Domain vectors- Use these to train the network Targets=X(5,tempidx(1:PtsTrain)); % Desired targets- Use for training. TestPattern=X(1:4,tempidx(PtsTrain+1:end)); %Put these into the network after training TestTargets=X(5,tempidx(PtsTrain+1:end)); %See if TestPattern modeled these values % % Now call the LinearNet routine, and see how well the Linear Network does % using the TestPattern data as input (compare with TestTargets). %