How can I write different ouput values for each for-loop?
Show older comments
I am trying to write the outputs in a text file using with the for loop and a function. After working the code in thee workspace I see the outputs for MAPE values at the each loop but in the text file it gets the one value it does not change. I use neural network function for MAPE values.How can I write the different MAPE values for each loop in the text file?
fileID=fopen('Donguu.txt','w+');
for lrate=0.1:0.2:0.2
for trainingrate=0.2:0.4:0.8
for n1=3:2:7
for n2=6:2:10
NeuralNetwork(Input, Target, trainingrate, n1, n2, lrate);
fprintf(fileID, '%d, %d, %d, %d, %d\n', lrate, trainingrate, n1, n2, MAPE);
end
end
end
end
lrate=6.000000e-01, trainingrate=2.000000e-01, n1=3, n2=6
MAPE =
0.6875
lrate=6.000000e-01, trainingrate=2.000000e-01, n1=3, n2=8
MAPE =
0.6354
lrate=6.000000e-01, trainingrate=2.000000e-01, n1=3, n2=10
MAPE =
0.7353
6 Comments
Walter Roberson
on 10 Sep 2018
You do not appear to be writing to a text file: your fprintf() does not have a file identifier as the first parameter, and you are not passing a file identifier to NeuralNetwork() to write to.
Are you using diary() to write to a text file?
Perihan Bilgeç
on 10 Sep 2018
Geoff Hayes
on 10 Sep 2018
Perihan - do you close the file with fclose?
Walter Roberson
on 10 Sep 2018
MAPE is not calculated by any of the code you posted. Is NeuralNetwork doing an assignin('caller', 'MAPE', ...) or is it simply displaying the value ?
Perihan Bilgeç
on 10 Sep 2018
Perihan Bilgeç
on 10 Sep 2018
Edited: Walter Roberson
on 10 Sep 2018
Accepted Answer
More Answers (1)
Perihan Bilgeç
on 11 Sep 2018
0 votes
Categories
Find more on Operations on Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!