How can I tell MatLab to give the user a yes or no question?

7 views (last 30 days)
Here is the first part of my code. The purpose is to find out if the user wants the volume of a pyramid, cone, or torus and to give the formula depending on the inputs. I keep getting an error message that says that Y is undefined so how can I tell MatLab that Y is yes and to continue with the script?
x=input('Do you need the volume of a pyramid?, Y/N'); if x==Y ------------------------------------------------------------ --------b=input('What is the length of the base?');------------------------------------------------------------------------------ ------- h=input('What is the hight?');--------------------------------------------------------------------------------------------- ------- Answer=(1/3)*(b*h);------------------------------------------------------------------------------------------------ ---- -- ------ disp('The area of the pyramid is:')--------------------------------------------------------------------------------- ------ ------ Answer--------------------------------------------------------------------- --------------------------------------------------- ------ end--------------------------------------------------------------------------------------------------------------------------------- ------ if x=='N'------------------------------------------------------------------------------------------------------------------ continue y=input('Do you need the volume of a cone?, Y/N'); if n=='Y'
and it goes on blah blah blah

Answers (1)

Image Analyst
Image Analyst on 13 Feb 2014
You can use questdlg() or inputdlg(). Look at the examples in the help.

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!