Y axis named after a String value from a listbox selection

1 visualización (últimos 30 días)
Lina
Lina el 10 de Mzo. de 2015
Respondida: Lina el 25 de Mzo. de 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?

Respuesta aceptada

Lina
Lina el 25 de Mzo. de 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 :)

Más respuestas (1)

dpb
dpb el 10 de Mzo. de 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...

Categorías

Más información sobre Desktop en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by