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 Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by