XTrain_ZaMir = (XTrain_ZaMir - mu_ZaMir)/sig_ZaMir;
YTrain_ZaMir = (YTrain_ZaMir - mu_ZaMir)/sig_ZaMir;
XTrain_ZaMir = XTrain_ZaMir(:,1:end-4);
YTrain_ZaMir = YTrain_ZaMir(:,5:end);
Test_ZaMir = [flowTe_ZaMir flowTeOther_ZaMir]';
nt = floor(0.7*length(Test_ZaMir));
YTest_ZaMir = Test_ZaMir(1,1:end);
XTest_ZaMir = Test_ZaMir(1,1:end);
XTest_ZaMir = (XTest_ZaMir - mu_ZaMir)/sig_ZaMir;
YTest_ZaMir = (YTest_ZaMir - mu_ZaMir)/sig_ZaMir;
XVal_ZaMir = XTest_ZaMir(:,1:nt-4);
YVal_ZaMir = YTest_ZaMir(:,5:nt);
XTest_ZaMir = XTest_ZaMir(:,nt+4:end-1);
YTest_ZaMir = YTest_ZaMir(:,nt+5:end);
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numResponses)
options = trainingOptions('adam', ...
'MaxEpochs',maxepochs, ...
'GradientThreshold',1, ...
'InitialLearnRate',0.005, ...
'ValidationData',{XVal_ZaMir,YVal_ZaMir},...
'ValidationFrequency',20,...
'Shuffle','every-epoch',...
'MiniBatchSize',minibatchsize,...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',150, ...
'LearnRateDropFactor',0.005, ...
'Plots','training-progress');
[net,info] = trainNetwork(XTrain_ZaMir,YTrain_ZaMir,layers,options);
[net,YPred_ZaMir]= predictAndUpdateState(net,XTest_ZaMir);
numTimeStepsTest= (0.5*floor(length(XTest_ZaMir)));
for i = 2:numTimeStepsTest
[net,YPred_ZaMir(:,i)] = predictAndUpdateState(net,XTest_ZaMir(:,i-1),'ExecutionEnvironment','cpu');
YTest_ZaMir = sig_ZaMir*YTest_ZaMir + mu_ZaMir;
YPred_ZaMir = sig_ZaMir*YPred_ZaMir + mu_ZaMir;