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 个评论

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

请先登录,再进行评论。

 采纳的回答

EDIT
sprintf('%s_%d', 'modelsq', gesNum);

2 个评论

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

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Characters and Strings 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by