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)
Show older comments
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?
2 Comments
Walter Roberson
on 15 May 2017
menu() is not a popup menu. They might be expecting you to use uicontrol() style popup
Answers (1)
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
See Also
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!