If-elseif-else-end structure doesn't work properly
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
lbon jbn
am 24 Nov. 2011
Kategorien
Mehr zu Spline Postprocessing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!