Y axis named after a String value from a listbox selection

1 Ansicht (letzte 30 Tage)
Lina
Lina am 10 Mär. 2015
Beantwortet: Lina am 25 Mär. 2015
______________________________________________________________________
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?

Akzeptierte Antwort

Lina
Lina am 25 Mär. 2015
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 :)

Weitere Antworten (1)

dpb
dpb am 10 Mär. 2015
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...

Kategorien

Mehr zu Desktop finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by