Clear Filters
Clear Filters

another quick question about string read

2 views (last 30 days)
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 Comment
Jan
Jan on 13 Feb 2013
@UTA: The documentation of sprintf does explain this clearly, so please read again:
help sprintf
doc sprintf

Sign in to comment.

Accepted Answer

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

Sign in to comment.

More Answers (1)

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

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!