How to display strings with static text and varying numbers in text box?
3 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 String 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!