creating a menu for a .MAT file.
Show older comments
Hi, I have a .MAT file containing information regarding currency changes and need to make a interactive menu for this.
I have tried to use X = menu('name', 'option1', 'optionN'); but cannot get this to work.
I am not very well versed in the art of the MATLAB, and thus I do not know how to import the data from my file into this command.
Any ideas for how this can be solved?
Thanks in advance (-:
Answers (1)
dpb
on 1 Feb 2021
Your data doesn't go into the menu; it is simply a selection mechanism for the user to pick a specific action; one then has to write the code that goes along with the possible selections to do what the particular menu item implies.
I see the example in the documentation for how that is done isn't perhaps as clear in what is done as could be; the figure interrupts the code:
t = 0:.1:60;
s = sin(t);
color = ['r','b','g']
choice = menu('Choose a color','Red','Blue','Green')
plot(t,s,color(choice))
Running the above code snippet will draw the sine plot in the selected color picked out of the array color by the returned index variable, choice
If it is different code paths, a switch...end block is often the easiest construct.
1 Comment
Bjørnar Århaug
on 2 Feb 2021
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!