Displaying multiple values separately

36 ビュー (過去 30 日間)
D.J
D.J 2018 年 9 月 19 日
コメント済み: D.J 2018 年 9 月 19 日
Hello all, I have a code which calculates 2 values,one for a1=1217 and the other is for a2=-845.42. Although the code is working correctly, the end results comes as:
a1 & a2=
1217
-845.42
How can I display the end results as:
a1=1217
a2=-845.42
The code for reporting I used is :
disp('a1 & a2='); disp(a)
% where a=T\P;
I think I should use fprintf but I am not sure how.
I hope my question makes sense. Many thanks

採用された回答

Stephen23
Stephen23 2018 年 9 月 19 日
編集済み: Stephen23 2018 年 9 月 19 日
>> a = [1217,-845.42];
>> fprintf('a1 = %g\na2 = %g\n',a)
a1 = 1217
a2 = -845.42
  3 件のコメント
Stephen23
Stephen23 2018 年 9 月 19 日
@D.J: that's great! Remember to accept my answer!
D.J
D.J 2018 年 9 月 19 日
Sorry, just did...

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

その他の回答 (1 件)

KSSV
KSSV 2018 年 9 月 19 日
a1 = rand ;
a2 = rand ;
fprintf('a1 = %f, a2 = %f\n',a1,a2)

カテゴリ

Help Center および File ExchangeTransmitters and Receivers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by