another quick question about string read

조회 수: 1 (최근 30일)
UTA
UTA 2013년 2월 13일
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