another quick question about string read

gesNum = 6;
I want to get modelsq_6 other than modelsq_gesNum by using : sprintf('%s_%s', 'modelsq', 'gesNum'); I know this is wrong way, so how should I do?

1 commentaire

@UTA: The documentation of sprintf does explain this clearly, so please read again:
help sprintf
doc sprintf

Connectez-vous pour commenter.

 Réponse acceptée

José-Luis
José-Luis le 13 Fév 2013
Modifié(e) : José-Luis le 13 Fév 2013
EDIT
sprintf('%s_%d', 'modelsq', gesNum);

2 commentaires

UTA
UTA le 13 Fév 2013
it is not work, it only shows modelsq_
My bad, forgot to change the integer identifier, please try:
gesNum = 6;
sprintf('%s_%i', 'modelsq', gesNum);

Connectez-vous pour commenter.

Plus de réponses (1)

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by