Y axis named after a String value from a listbox selection

3 ビュー (過去 30 日間)
Lina
Lina 2015 年 3 月 10 日
回答済み: Lina 2015 年 3 月 25 日
______________________________________________________________________
I would like my Y axis to be named after a String value from a listbox selection. I have many Strings,named Anna, Maria,Eva,etc. I did this so far:
______________________________________________________________________
Locate_list=findobj(gcf,'Tag','Listbox'); % locate listbox
*String_Value* =get(Locate_list,'Value'); % get string number
........
ylabel(['Name:', *String_Value* ]);
______________________________________________________________________
It gives me a Y label with the number of the string in the list. I would like to have the string name itself. For example:
Name: Anna
instead of:
Name: 2
______________________________________________________________________
Any ideas?

採用された回答

Lina
Lina 2015 年 3 月 25 日
Figured it out! I had to use
Locate_list=findobj(gcf,'Tag','Listbox'); % locate listbox
String=str2num(get(Locate_list,'String'));
String_Value =get(Locate_list,'Value'); % get string number
figure('...')
.....
.....
ylabel(['Name:', num2str(*String*(*String_Value*)) ]);
And I get a nice label including the text:
Name: Anna , where Anna was in the listbox as a one of the strings :)

その他の回答 (1 件)

dpb
dpb 2015 年 3 月 10 日
In what variable array are the strings stored for the dialog listbox? Use the index returned into that array to retrieve the value...
ylabel(ThatStringArrayOfStrings(String_Value))
The above presumes a cellstring array; use the 2D addressing from with a character array
ylabel(ThatStringArrayOfStrings(String_Value,:))
I don't know gui's well enough but I'd think there's a more direct access to the listbox return value than findobj and get, though? Look thru the examples for guidance there or maybe a GUI guru will drop in...

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by