Matlab Gui Help request !!
조회 수: 1 (최근 30일)
이전 댓글 표시
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148115/image.png)
댓글 수: 0
채택된 답변
Adam
2015년 3월 19일
편집: Adam
2015년 3월 19일
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.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!