How would i write this str?

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일

1 개 추천

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.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2023년 12월 6일

댓글:

2023년 12월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by