How can I write different ouput values for each for-loop?
이전 댓글 표시
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
Walter Roberson
2018년 9월 10일
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ç
2018년 9월 10일
Geoff Hayes
2018년 9월 10일
Perihan - do you close the file with fclose?
Walter Roberson
2018년 9월 10일
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ç
2018년 9월 10일
Perihan Bilgeç
2018년 9월 10일
편집: Walter Roberson
2018년 9월 10일
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Operations on Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!