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 Comment

@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

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);

Sign in to comment.

Categories

Tags

No tags entered yet.

Asked:

UTA
on 13 Feb 2013

Community Treasure Hunt

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

Start Hunting!