Hi Soni,
You have to approach this in two steps. Firstly, you need to learn to use some basic features of GUIDE. Thus,
- Watch the demo Creating a GUI with GUIDE. It is good!
- 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
- 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.
- Write a little description on how the user is supposed to use the GUI.
- 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"
function calculate_Callback(hObject, eventdata, handles)
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' )
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
before you start your GUI
.
Be aware that this is sketchy!
--- To be continued ---
Best Answer