フィルターのクリア

How to print .txt from the matrix containing numbers and characters?

2 ビュー (過去 30 日間)
M.R. Ebrahimi
M.R. Ebrahimi 2020 年 10 月 12 日
コメント済み: M.R. Ebrahimi 2020 年 10 月 12 日
I want to print the following data into a .txt file.
1 0 R 1km
2 0 R 1km
3 0 R 1km
......
.....
99 0 R 1km
100 0 R 1km
How can I use fprintf to save this data?

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 12 日
Something like this
tt = table((1:100).', zeros(100,1), repmat('R', 100, 1), repmat('1km', 100, 1));
writetable(tt, 'data.txt', 'WriteVariableNames', false, 'Delimiter', '\t')
  4 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 10 月 12 日
Try this
tt = table((1:100).', zeros(100,1), repmat('R', 100, 1), repmat('1km', 100, 1));
C = table2cell(tt).';
f = fopen('test.txt', 'w');
fprintf(f, '%f\t%f\t%s\t%s\n', C{:});
fclose(f);
M.R. Ebrahimi
M.R. Ebrahimi 2020 年 10 月 12 日
Thanks alot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by