Create two fprintf in two diferent lines

7 ビュー (過去 30 日間)
Torkan
Torkan 2019 年 11 月 15 日
回答済み: Torkan 2019 年 11 月 15 日
Hello,
I want to separate the third fprintf from the second one. The code below first gives two first fprintfs correct however, it continues to print the third fprintf along the second row. How could I separate these?
fprintf(' E_11 \t E_11avg \t E_22\t E_22avg\n');
fprintf('%2.0f\t %2.0f\t %2.0f\t %2.0f\t',[E_11; E_11avg; E_22; E_22avg]);
fprintf(' B1 \t B2 \t B3\t B4 \t B5\n');
fprintf('%2.0f\t %2.0f\t %2.0f\t %2.0f\t',[BB(1,1); BB(2,1); BB(3,1); BB(4,1); BB(5,1)]);
thanks

採用された回答

Guillaume
Guillaume 2019 年 11 月 15 日
編集済み: Guillaume 2019 年 11 月 15 日
You seem to be aware that '\n' is a newline so why don't you use it?
fprintf('\n B1 \t B2 \t B3\t B4 \t B5\n'); %\n added at the beginning of the 3rd fprintf
edit: actually if I understand what you're actually doing, you probably want to replace the last '\t' on the second line by a '\n':
fprintf('%2.0f\t %2.0f\t %2.0f\t %2.0f\n',[E_11; E_11avg; E_22; E_22avg]);
And if you're not aware of what the various escape characters do, see the doc of fprintf.
  2 件のコメント
Torkan
Torkan 2019 年 11 月 15 日
Thanks you
Now if I want to have space between each row what should I do? Or write caption above each one maybe using disp?
Guillaume
Guillaume 2019 年 11 月 15 日
Add another '\n' to add an empty line.

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

その他の回答 (1 件)

Torkan
Torkan 2019 年 11 月 15 日
Yep I got that

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by