another quick question about string read

1 Ansicht (letzte 30 Tage)
UTA
UTA am 13 Feb. 2013
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 Kommentar
Jan
Jan am 13 Feb. 2013
@UTA: The documentation of sprintf does explain this clearly, so please read again:
help sprintf
doc sprintf

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

José-Luis
José-Luis am 13 Feb. 2013
Bearbeitet: José-Luis am 13 Feb. 2013
EDIT
sprintf('%s_%d', 'modelsq', gesNum);
  2 Kommentare
UTA
UTA am 13 Feb. 2013
it is not work, it only shows modelsq_
José-Luis
José-Luis am 13 Feb. 2013
My bad, forgot to change the integer identifier, please try:
gesNum = 6;
sprintf('%s_%i', 'modelsq', gesNum);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 13 Feb. 2013
sprintf('modelsq_%d', gesNum);

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by