Is it possible to combine strings and variables in a matrix?
4 ビュー (過去 30 日間)
古いコメントを表示
I have a matrix A and A= [x y]. X and y are both defined by constants: 3 and 4, respectively.
Now, how do I make it so that I not only get A to show up as 3 4 but as x=3 and y=4.
I tried this A= ['x='x 'y='y] but it does not work.
Thanks!
0 件のコメント
採用された回答
Pourya Alinezhad
2013 年 6 月 18 日
編集済み: Pourya Alinezhad
2013 年 6 月 18 日
disp(['rate:',num2str(rate),'duration:',num2str(duration)])
3 件のコメント
その他の回答 (1 件)
random09983492
2013 年 6 月 18 日
Hi Z,
Here are 2 solutions:
1. Change:
disp [rate, duration]
to:
disp([rate, duration])
2. Use fprintf statement instead of disp like such:
fprintf('rate = %d, duration = %d', rate, duration);
This will produce your "even better" result, I think. If not, let me know what you would like.
Elliot
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!