How create string like this: word+number+word with number=num2str(x)
Mostra commenti meno recenti
Hi everyone,
how could I write a string like the following word+number+word with number=num2str(x). For example:
x=2; x_str=num2str(x); y='I have' x_str 'dogs'
Thank you for your help.
Risposta accettata
Più risposte (1)
Walter Roberson
il 9 Mag 2017
y = sprintf('I have %d dogs', x);
2 Commenti
Gennaro Arguzzi
il 9 Mag 2017
Walter Roberson
il 9 Mag 2017
MATLAB does not have a string data type before R2016b, on character vectors. It is common to put character vectors inside cell arrays, such as
{sprintf('I have %d dogs', x), 'I have no cats', sprintf('I have %d iguanas', y) }
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!