Writing to a text file
3 ビュー (過去 30 日間)
古いコメントを表示
Hi All, I want to save a matrix in a text file. fprintf and fwrite both create the .txt file in ASCII format which is not what I want. This is what I've got:
Cyle=[1 2 3];
fid=fopen('Output.txt','w');
fprintf(fid,char(Cyle),'char'); %// or fwrite(fid,char(Cyle),'char');
fclose(fid);
Is there a way around it?
Also, can I add a comment on the first line of the text file?
Thanks Sina
0 件のコメント
回答 (1 件)
Star Strider
2015 年 3 月 2 日
If you don’t want to save it as an ASCII file, use the save function to save it as a binary file. You can also save the comment.
Example:
Cyle=[1 2 3];
Comment = 'I really like the way MATLAB solved this problem!';
save('MyData.mat', 'Comment', 'Cyle')
or alternatively:
save MyData.mat Comment Cyle
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!