필터 지우기
필터 지우기

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 CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by