how to insert mfile to GUI
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
per isakson
il 4 Set 2012
Modificato: per isakson
il 4 Set 2012
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"
% --- 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 Commenti
per isakson
il 5 Set 2012
Modificato: per isakson
il 5 Set 2012
Back to step 1! Keep it simple. Download 41 Complete GUI Examples and put them in a separate folder. Use them and the Matlab help!
The "check buttons" (or rather radio buttons) are probably in a hggroup, which automagically unselect all others when you select one of them.
Are you saying that the change of the static text is not intended? Do not include code that you do not understand.
I guess that you have some code in the callback triggered by the radio button that changes the static text. Compare the code-snippet below, which comes from the example "GUI with UiControls"
% --- Executes when selected object changed in unitgroup.
function unitgroup_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in unitgroup
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if (hObject == handles.english)
set(handles.text4, 'String', 'lb/cu.in');
set(handles.text5, 'String', 'cu.in');
set(handles.text6, 'String', 'lb');
else
set(handles.text4, 'String', 'kg/cu.m');
set(handles.text5, 'String', 'cu.m');
set(handles.text6, 'String', 'kg');
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Desktop in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!