Hi everyone. I am new to MATLAB and i need help evaluating the following question especially part (b) since i dont quite understand it. I am not convinced my code answers the question asked.Thank you.

1 view (last 30 days)
Include your MATLAB statement and a screen shot of your pop-up menu.
(a) Write a menu statement that instructs the user to choose one of the following interpolation schemes: Nearest, Linear, or Spline and saves the user’s choice under the variable, Method.
(b) In part (a), what is the variable, Method, if the user chooses Linear?

Answers (1)

Cam Salzberger
Cam Salzberger on 15 May 2017
Edited: Cam Salzberger on 15 May 2017
Hey George,
This is a pretty confusingly-worded quesiton. Walter is right that "menu" does not produce a pop-up the way that a uicontrol with the Style 'popupmenu' would. However, using "menu" is the only way that question (b) makes any kind of sense. Maybe they meant that is creates a dialog box that "pops up" on the screen?
If you use "menu", then unlike the superior questdlg or something like that, the output is the index of the choice selected. For example:
choiceIdx = menu('My question?','A','B','C');
if the user selects "C", then "choiceIdx" would have the value 3. Generally you would instead use this like:
x = rand(10);
options = {'omitnan','includenan'};
choiceIdx = menu('Would you like to omit or include NaNs?',options);
y = max(x,options{choiceIdx});
Hope that gives you some background on why someone might do this.
-Cam
  3 Comments
GEORGE WAYNE MWANGI
GEORGE WAYNE MWANGI on 15 May 2017
Edited: GEORGE WAYNE MWANGI on 15 May 2017
How would one use uicontrol() in the above case? Please use the above code to explain it to me. Thank you.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!