Vector as ItemsData property in List Box
Mostrar comentarios más antiguos
Hi all,
im coding a fairly easy app with app designer and im struggling with the input/output for List Box property "ItemsData".
What i want to do is to show the user 2 options ("Items") in a list-box. These options then lead to vectors of 2 numbers ("ItemsData"). Lets say:
With ItemsData(Option 1) = [2950 3350] and ItemsData(Option 2) = [3600 4500]Now i want to use these 2 integers in my main function and i cant figure out how to do the indexing right. I tried using a cell array as ItemsData with combined indexing:
A = B{1,1}(1,1)
which leeds to an error because of the curly brackets.
If it is any easier with a Switch or DropDown its fine too! There are just 2 options.
Thanks for any help on this!
Respuesta aceptada
Más respuestas (1)
Simon Chan
el 21 de Ag. de 2022
Suppose the listbox is defined as follows and ItemsData are given in your example.
app.ListBox = uilistbox(app.UIFigure);
You may get the data directly via the following:
A = app.ListBox.Value
8 comentarios
Oskar Kilgus
el 21 de Ag. de 2022
Simon Chan
el 21 de Ag. de 2022
Try this:
A = app.ListBox.Value(1)
Oskar Kilgus
el 21 de Ag. de 2022
Simon Chan
el 21 de Ag. de 2022
I think you use the value 2950 in another function which requires a lower and upper limit as well.
So you need to define the limits before you use this value on another function. Or the limits you already defined does not cover the value '2950' and hence it gives the above mentioned error.
Could you please let me know the function you are going to use the value '2950'?
Oskar Kilgus
el 21 de Ag. de 2022
Editada: Oskar Kilgus
el 21 de Ag. de 2022
Oskar Kilgus
el 21 de Ag. de 2022
Simon Chan
el 21 de Ag. de 2022
Could you please check whether the following lines gives the correct values to you or not?
app.choosefromListBox.Value(1) % gives 2950 to another function
app.choosefromListBox.Value(2) % gives 3350 to another function
Oskar Kilgus
el 21 de Ag. de 2022
Editada: Oskar Kilgus
el 21 de Ag. de 2022
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!