Problem in displaying or printing final result.

3 ビュー (過去 30 日間)
Masoud Dorvash
Masoud Dorvash 2021 年 1 月 21 日
コメント済み: Masoud Dorvash 2021 年 1 月 21 日
Hi everybody,
I need help in my codding, the code and my final results are as below:
[rYY_es_Max, rYY_es_Lags] = max(rYY_es);
[rYY_Max , rYY_Lags] = max(rYY);
[rYY_ideal_Max , rYY_ideal_Lags] = max(rYY_ideal);
Maximum_rYY_es = ['Estimated rYY_Max = ', num2str(rYY_es_Max), ' The Point of Maximization = ', num2str(m(rYY_es_Lags))];
Maximum_rYY = ['rYY_Max = ', num2str(rYY_Max), ' The Point of Maximization = ', num2str(m(rYY_Lags))];
Maximum_rYY_ideal = ['rYY_ideal_Max = ', num2str(double(rYY_ideal_Max)), ' The Point of Maximization = ', num2str(m(rYY_ideal_Lags))];
disp(Maximum_rYY_es)
disp(Maximum_rYY)
disp(Maximum_rYY_ideal
Estimated rYY_Max = 2.9497 The Point of Maximization = 0
rYY_Max = 2.9898 The Point of Maximization = 0
rYY_ideal_Max = 3 The Point of Maximization = 0
I just want to enhance the visual output; so I want to make all 'The point of Maximization = 0' sentences in line. the problem is the numbers can varry for example for the first one it can display 2.95 so I can not use Blank to fix this problem, I was just wondering if is it possible to make a Matrix of strings and numbers to make eveything in place and line or not?
or is there any other soloution to this problem?
  1 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 1 月 21 日
hello
you can force num2str to generate same length strings using following option :
>> num2str(pi,'%.4f')
ans =
'3.1416'
>> num2str(1,'%.4f')
ans =
'1.0000'

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

採用された回答

Mischa Kim
Mischa Kim 2021 年 1 月 21 日
Hi Masoud, use fprintf instead. Check out the examples in the link.

その他の回答 (0 件)

カテゴリ

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