save variables in a file

조회 수: 1 (최근 30일)
barbara
barbara 2011년 5월 9일
I need to save in a .txt file some of the variables calculated. Each variables should occupy one column separated by tab. What is the most appropriate way of doing it?
with the line:
save('q20.txt','p','D','de','A','L','W','Per','RFF','En','D','Lm','Wm','Aratio','N2D','N3D','a','Df2D','Df3D','-ascii', '-tabs')
I save the variables in one file. But the variables are listed one below the other .
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 9일
fid = fopen('q20.txt','wt');
fprintf(fid, [repmat('%g\t',1,17),'%g\n'], [p(:), D(:), de(:), A(:), L(:), W(:), Per(:), RFF(:), En(:), D(:), Lm(:), Wm(:), Aratio(:), N2D(:), N3D(:), a(:), Df2D(:), Df3D(:)].' );
fclose(fid);
Note: the dot-apostrophe after the close-square-bracket is required for proper output

추가 답변 (1개)

barbara
barbara 2011년 5월 9일
Thank you so much

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by