If-elseif-else-end structure doesn't work properly
Mostrar comentarios más antiguos
Hello, I am having some issues with a volume calculating program I am trying to create. For whatever reason, after a volume is calculated, the program does not end, it jumps to the next solid to calculate its volume. For example, if I have just calculated the volume of a sphere, it will then go to the cube function and begin asking for inputs related to that function. I don't understand why it just doesn't end. When the functions are run separately, they end fine. But when ran through the 'main' program (the piece of code below), the issue I mentioned pops up. Any suggestions?
solid = input('Welcome to Volume Calculator - Please enter the solid for which you would like to calculate the volume: ');
if solid == cube
volume = cube(a)
elseif solid == sphere
volume = sphere(r)
elseif solid == prism
volume = prism(a,b,c)
else disp('Only certain solids can be calculated. Please try again')
end
Respuesta aceptada
Más respuestas (1)
lbon jbn
el 24 de Nov. de 2011
2 comentarios
Walter Roberson
el 24 de Nov. de 2011
if any(r < 0)
if all(r < 0)
lbon jbn
el 24 de Nov. de 2011
Categorías
Más información sobre Spline Postprocessing 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!