printing two columns into text
16 ビュー (過去 30 日間)
古いコメントを表示
Nalini Nadupalli
2015 年 10 月 26 日
コメント済み: Nalini Nadupalli
2015 年 10 月 26 日
I have the following code and what ever I do, I m not able to print the two vectors as columns side by side. Please help.
A = [1;2;3];
B= [4;5;6];
fid = fopen('Myfiles.txt', 'w');
fprintf(fid, '%u %u \n', [A B]');
fclose(fid);
It prints as
1 4 2 5 3 6
But I want it as
1 4
2 5
3 6
Where am I going wrong? Thanks for your help.
0 件のコメント
採用された回答
Image Analyst
2015 年 10 月 26 日
For me it doesn't. It works just fine:
A = [1;2;3]
B = [4;5;6]
fid = fopen('Myfiles.txt', 'w');
fprintf(fid, '%u %u \n', [A B]');
% sprintf('%u %u \n', [A B]')
fclose(fid);
type 'Myfiles.txt'
%delete('Myfiles.txt');
The type statement writes it out the command window and it looks just fine. If it doesn't for you, then, in fopen(), try using 'wt' instead of 'w' and see if that makes it look better.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!