Listbox problem in GUI

1 visualización (últimos 30 días)
VBBV
VBBV el 24 de Jun. de 2018
Comentada: Walter Roberson el 24 de Jun. de 2018
I have a GUI which has listbox in which I want to display numbers in first followed by strings or names The excel file has numbers and texts/names. How can I display both numbers and text in listbox using pushbutton callback Matlab is treating text as 'NaN' and I want to convert them to strings and display as text in listbox ...

Respuesta aceptada

Walter Roberson
Walter Roberson el 24 de Jun. de 2018
You need to initialize the listbox as a cell array and use {} indexing with it. For example,
s = {3; 'hello'};
h = uicontrol('style','list','string', s);
...
hv = get(h,'Value');
hall = get(h,'String');
hcurrent = hall{hv}
  6 comentarios
VBBV
VBBV el 24 de Jun. de 2018
it show 59 x 3 char array
Walter Roberson
Walter Roberson el 24 de Jun. de 2018
It is not possible for a numeric array to contain both text and numbers.
If you are using xlsread() then the first output would be pure numeric with no text, and the second output would be pure text with no numeric, and the third output ("raw") would be a cell array in which individual entry could be either numeric or character vector. As that is the only way to get a mix of numeric and text with xlsread(), I assumed that you were working with that third output of xlsread()
I just corrected a typing mistake in the code I posted.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by