display strings in uipanels

hi everybody. in my coding, it display a list of string e.g. : 'one' 'two' 'three'. however, it just diplay one in my uipanel interface. why is that? How to put complete One Two Three in my uipanels interface?I should use strcat or strread or hows?

 採用された回答

Image Analyst
Image Analyst 2012 年 10 月 8 日

0 投票

Setting the string property on the panel only sets the caption for the panel. If you want more than that, you need to have static text labels inside the panel. You can create them with sprintf(). If you want multiple lines in your text, then put in a \n when you create the string:
txtInfo = sprintf('The first number = %d\nThe second number = %f', a, b);
set(handles.txtInfo, 'String', txtInfo);

3 件のコメント

Tulips
Tulips 2012 年 10 月 8 日
編集済み: Tulips 2012 年 10 月 8 日
Mr Analyst, I can display the string already for it displays something like this:
one
two
three
how to arrange the string like this: one,two and three
Image Analyst
Image Analyst 2012 年 10 月 8 日
How many text labels is that? 3 or just one?
Anyway, to have them all in one line:
string1 = 'one';
string2 = 'two';
string3 = 'three';
txtInfo = sprintf('%s\n%s\n%s', string1, string2, string3);
set(handles.txtInfo, 'String', txtInfo);
Tulips
Tulips 2012 年 10 月 9 日
thanks a lot!it works!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by