another quick question about string read

1 次查看(过去 30 天)
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 个评论
Jan
Jan 2013-2-13
@UTA: The documentation of sprintf does explain this clearly, so please read again:
help sprintf
doc sprintf

请先登录,再进行评论。

采纳的回答

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

请先登录,再进行评论。

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-2-13
sprintf('modelsq_%d', gesNum);

类别

Help CenterFile 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