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 comentario

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

Iniciar sesión para comentar.

 Respuesta aceptada

José-Luis
José-Luis el 13 de Feb. de 2013
Editada: José-Luis el 13 de Feb. de 2013
EDIT
sprintf('%s_%d', 'modelsq', gesNum);

2 comentarios

UTA
UTA el 13 de Feb. de 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);

Iniciar sesión para comentar.

Más respuestas (1)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

UTA
el 13 de Feb. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by