フィルターのクリア

Problem about Output in a txt file?How to solve it

2 ビュー (過去 30 日間)
tabw
tabw 2014 年 9 月 13 日
編集済み: Rick Rosson 2014 年 9 月 13 日
x = 0:.1:1;
A = [x; exp(x)];
fileID = fopen('exp.txt','w');
fprintf(fileID,'%6s %12s\n','x','exp(x)');
fprintf(fileID,'%6.2f %12.8f\n',A);
fclose(fileID);
x exp(x)
0.00 1.00000000
0.10 1.10517092
0.20 1.22140276
0.30 1.34985881
0.40 1.49182470
0.50 1.64872127
0.60 1.82211880
0.70 2.01375271
0.80 2.22554093
0.90 2.45960311
1.00 2.71828183
Can I add data and output it row by row? like
x exp(x)
0 1
then I could add one more row without to define the x again?
x exp(x)
0 1
0.4 1.49
it is because the result inside a for loop each time only output one row.
But,I don't want store all the result into matrix ,then like what I do above.
I want each time after 1 loop it can add one row.
like writing stuff in csv file result(1,i) result(1,i+1)

採用された回答

Rick Rosson
Rick Rosson 2014 年 9 月 13 日
編集済み: Rick Rosson 2014 年 9 月 13 日
Open the file with permission set to append:
fileID = fopen('exp.txt','a');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by