How to use switch statement with list box?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi! :)
Please see the attached code.
What I dont understand is what I have done wrong here . I think the code runs when I dont click cancel on the listbox but when I choose cancel from the listbox, I get error.
Have I done something wrong writing if statement within otherwise and using empty as an option there..?
Please run the code with for instance samlet_akivitet=0.5 and temperature =30 ;
Thanks
0 comentarios
Respuestas (1)
Walter Roberson
el 4 de Nov. de 2023
When you ask to cancel then indx is empty, []. The empty matrix is not considered to be a scalar -- a scalar is 1 x 1 but [] is 0 x 0. And when you ask to switch on something, you need to switch on a scalar or on a character vector
You need to re-order your code. After the listdlg() test
if ~tf
osmotic_pressure= [];
disp('You have not chosen any value for ME.')
error_osm=1;
return
end
Now you can switch() indx and be certain that indx is a scalar.
0 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!