How would i write this str?

13 vues (au cours des 30 derniers jours)
Maria
Maria le 6 Déc 2023
Commenté : Dyuman Joshi le 6 Déc 2023
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'

Réponses (1)

Image Analyst
Image Analyst le 6 Déc 2023
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 commentaire
Dyuman Joshi
Dyuman Joshi le 6 Déc 2023
+1 for fprintf

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by