SWITCH expression must be a scalar or a character vector. issue
Mostrar comentarios más antiguos
Hi im trying to calculate price of 1,2,3 or more glass of milk. 1 glass of milk must be 1.75$ 2 is 3.0$ 3 is 3.5$ and for more glass 3.5$ + 0.5+ for every glass, but i am getting this error "SWITCH expression must be a scalar or a character vector". Any idea ? i check forum before but answer i get dont solve my problem thx for any help. Btw my proffesor only accept the homework if i use "inputdlg" "msgbox(sprintf(", and switch case stracture.
box=inputdlg('how many glass of milk');
switch box
case '1'
price=1.75;
case '2'
price=3;
case '3'
price=3.5;
otherwise
price=3.5+(0.5)*x;
end
msgbox(sprintf('you must pay %f',price));
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Operators and Elementary Operations 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!