Matlab Gui Help request !!

1 view (last 30 days)
Mohamed Djama
Mohamed Djama on 19 Mar 2015
Edited: Adam on 19 Mar 2015
Hello there, currently am working on a matlab assignment which require to make a graphical user interface "Which i upload snap of it", therefore i have to relate it with .m file. when it comes to matlab am quite new with this programming language and i have to submit my project soon, so i want how to 1. get numerical "only positive numbers" from the user if not then prompt a message tells him "the input is wrong, please input The right values". 2. how to plot 3 data having the same x axes on the same box so which syntax should i have to use. 3. in selection panel i made a switch loop i don't know whether it's right or wrong but i have 3 options i want to load stored inputs when the user click on any one of them so what to do there. 4.the reset button i want when someone press it to remove everything and start the program again so what to do there. Thanks in advance

Accepted Answer

Adam
Adam on 19 Mar 2015
Edited: Adam on 19 Mar 2015
You should probably ask questions in different threads when you have so many to ask. Asking 4 different questions at once means either someone has to answer all 4 or they can only give a semi-complete answer to your question which can't then really get accepted as the answer since it doesn't cover everything.
1. To get numerical positive numbers from an edit box
val = str2double( get( hEdit, 'String' ) );
if isnan( val ) || val < 0
errordlg( 'Input must be a positive number' )
end
Obviously that is a very simple option, you can expand with extra arguments to errordlg or use a warndlg instead if you prefer, etc, etc
2. To plot data on the same axes just use
hold( hAxes, 'on' )
between your calls to plot.
3. I don't really know what your question is here. Do you not know how to load inputs (if so then you need to tell us where/what the inputs are to be loaded) or do you not know how to get the options from the popup list in your switch statement?
4. There are a few ways to do this. Personally I would probably have a function that resets everything in the UI back to default state, but simpler is probably something like:
closereq;
MyGUIName;
where MyGUIName is whatever the name is of your GUI that you use to launch it in the first place. Closing and reopening a UI just to reset it is not a very elegant user solution, but it is the one you asked for.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!