![1-10.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/237760/1-10.jpeg)
LISTBOX, PLEASE HELP ME WITH THE LISTBOX
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jules Ray
el 27 de Ag. de 2013
Editada: evgeny shumsky
el 10 de Sept. de 2019
Hello, i have posted some questions before about listbox but none give an answer....
my question is simple
i have this matrix:
a=1:1:10 % this is 1 2 3 4 5 6 7 8 9 10
i would like to load these numbers into a listbox, but i dont know how, must i change these numbers to char???
how ca i do this???? thanks in advance
1 comentario
evgeny shumsky
el 10 de Sept. de 2019
Editada: evgeny shumsky
el 10 de Sept. de 2019
if you wont it to be one under another
Mat=[1:10];
Mat = mat2cell(num2str(Mat')); % mat=mat' converts from row vector to column vector
set(handles.listbox,'string',Mat); % listbox ->tag of the listbox
![1-10.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/237760/1-10.jpeg)
Respuesta aceptada
David Sanchez
el 27 de Ag. de 2013
The array has to be transformed into a cell arrary:
a=1:1:10;
b=num2cell(a);
Then, send it to the popup menu:
set(handles.my_pop,'String',b);
7 comentarios
Image Analyst
el 28 de Ag. de 2013
What are all those things? Are any of them listboxes? Are you saying that your tag in GUIDE says listbox_1 and listbox_2 but in the code it doesn't? How are you running it? Are you clicking the green triangle in GUIDE or in MATLAB? I suspect that the figure you think you're running, you really aren't - you're running a different one.
Más respuestas (1)
Wayne King
el 27 de Ag. de 2013
a = inputdlg('Enter your vector');
% when dialog comes up enter, 1:10, click OK
a = str2num(cell2mat(a));
a is now a double precision vector
0 comentarios
Ver también
Categorías
Más información sobre Interactive Control and Callbacks 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!