MATLAB Answers

Finally i wrote this code for wind speed prediction with 3 parameters, why does my code has different prediction for the same dataset on each run?

5 views (last 30 days)
Morteza Hajitabar Firuzjaei
Edited: Torsten on 25 Jan 2018
load('input.mat');
X = tonndata(inputData(:,(1:3)),false,false);
T = tonndata(inputData(:,4),false,false);
N = 100; % Multi-step ahead prediction
inputSeries = X(1:end);
targetSeries = T(1:end);
inputSeriesVal = X(end-N+1:end);
targetSeriesVal = T(end-N+1:end);
delay = 1; %one hour
neuronsHiddenLayer = 10;
% Network Creation
net = narxnet(1:delay,1:delay,neuronsHiddenLayer);
[Xs,Xi,Ai,Ts] = preparets(net,inputSeries,{},targetSeries);
net = train(net,Xs,Ts,Xi,Ai);
view(net)
Y = net(Xs,Xi,Ai);
% Performance for the series-parallel implementation, only
% one-step-ahead prediction
perf = perform(net,Ts,Y);
[Xs1,Xio,Aio] = preparets(net,inputSeries(1:end-delay),{},targetSeries(1:end-delay));
[Y1,Xfo,Afo] = net(Xs1,Xio,Aio);
[netc,Xic,Aic] = closeloop(net,Xfo,Afo);
[yPred,Xfc,Afc] = netc(inputSeriesVal,Xic,Aic);
multiStepPerformance = perform(net,yPred,targetSeriesVal);
view(netc)
figure;
plot([cell2mat(targetSeries),nan(1,N);
nan(1,length(targetSeries)),cell2mat(yPred);]')
legend('Original Targets','Network Predictions')

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!