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 件のコメント

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 日

1 投票

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 日

1 投票

sprintf('modelsq_%d', gesNum);

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

タグが未入力です。

質問済み:

UTA
2013 年 2 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by