MATLAB Answers

how to insert mfile to GUI

7 views (last 30 days)
i have skripst in mfile to read and proces the data. i have 4 file mfile. 1 file to read and identification a file data, 1 file to proces many data, n 2 file to chose how many data u need to proces (day, mounth, year)
now i need insert the skript to the GUI..
can u help me..
  2 Comments
Soni huu
Soni huu on 4 Sep 2012
i dont know where to copy., i never use GUI..

Sign in to comment.

Accepted Answer

per isakson
per isakson on 4 Sep 2012
Edited: per isakson on 4 Sep 2012
Hi Soni,
You have to approach this in two steps. Firstly, you need to learn to use some basic features of GUIDE. Thus,
  1. Watch the demo Creating a GUI with GUIDE. It is good!
  2. Make a very simple GUI with three buttons, [Rain], [Sun], [Wind]. Pushing [Rain] shall show "It's raining" in the command window, etc.
When you are somewhat comfortable with doing the basic exercises you proceed to next step.
Design
  1. Make a simple sketch of the GUI you want to develop. Search "Design a GUI" in the online help. Make another sketch until you are happy with it. Remember professionals at The Mathworks have refined these descriptions over many years.
  2. Write a little description on how the user is supposed to use the GUI.
  3. You should try to minimize the interaction between your domain specific functions (the code that deals with weather, rain, etc.), e.g ReadManySoniData, and the GUI-code. You do not want to have many versions of the domain specific functions.
Implementation
This code snippet is copied from the example "GUI with UiControls"
% --- Executes on button press in calculate.
function calculate_Callback(hObject, eventdata, handles)
% hObject handle to calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mass = handles.metricdata.density * handles.metricdata.volume;
set(handles.mass, 'String', mass);
This function is called when the user push [Calculate]. I recommend that you include only a minimum of domain specific code in these callback-functions. Something like
disp( 'calculate_Callback' ) % to know that the function is executed
file_spec = handles.domaindata.file_spec;
RainData = ReadManySoniData( file_spec );
handles.domaindata.RainData = RainData;
when you debug the callback-function put a breakpoint at disp(...).
Later this may be replaced by
handles.domaindata.RainData=ReadManySoniData(handles.domaindata.file_spec);
.
Tip
An alternative to diagrams integrated in the GUI might be separate figures, e.g. created by plot. It is simple to implement. Cons: the GUI will be unhappy if you delete the figure without letting the GUI know and the figures tends to disappear under other windows. To avoid the latter download ALWAYSONTOP and run
alwaysontop auto
before you start your GUI
.
Be aware that this is sketchy!
--- To be continued ---
  5 Comments
Soni huu
Soni huu on 23 Jan 2013
sorry... long time no see... i have job in smallvillage, no internet conection.. i dont know how to design.. good design for my gui.. give me ur solution please..
I have to design GUI for my mfile code, this the illustration of process my matlab code
my GUI design (but i acepted any recommendation) :

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!