How would i write this str?

10 ビュー (過去 30 日間)
Maria
Maria 2023 年 12 月 6 日
コメント済み: Dyuman Joshi 2023 年 12 月 6 日
how would i format this,
MyAge = 6
FreindName = 'Joe'
FreindAge = 4
disp(['My',' friend',"'",'s', ' age is', FreindAge, ' years.'])
im trying to get it to display 'My freind's age is (veriable) years'

回答 (1 件)

Image Analyst
Image Analyst 2023 年 12 月 6 日
I always use fprintf
MyAge = 6;
FreindName = 'Joe';
FreindAge = 4;
fprintf("My friend %s's age is %d years.\n", FreindName, FreindAge)
My friend Joe's age is 4 years.
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 12 月 6 日
+1 for fprintf

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by