How to display strings with static text and varying numbers in text box?

조회 수: 1 (최근 30일)
Qianqian Pan
Qianqian Pan 2016년 9월 14일
댓글: Stephen23 2016년 9월 14일
I'm displaying a set of 200 images on screen in order. For each image displayed I have a text box in GUI showing which number is that image out of 200, like a count.
So for example, for the first image displayed, I want the text box showing '1 of 200', and for the second image displayed the text box will show '2 of 200', etc.
My original code was:
set(handles.text1,'String','%d of 200',i)
But it doesn't seem quite right. I guess the single quote is at the wrong place?
Can someone help me?

답변 (1개)

Stephen23
Stephen23 2016년 9월 14일
편집: Stephen23 2016년 9월 14일
You need to actually provide one string, not multiple arguments:
set(handles.text1,'String',sprintf('%d of 200',i))
  댓글 수: 2
Qianqian Pan
Qianqian Pan 2016년 9월 14일
Yes that's right! It works! Thanks for your prompt reply!!!!
Stephen23
Stephen23 2016년 9월 14일
@Qianqian Pan: I am glad that it works! Please accept my answer if it helped you to resolve your original question.

댓글을 달려면 로그인하십시오.

카테고리

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