Plotting in GUI using data from a different matlab program
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi MATLAB community,
I am using the MATLAB GUIDE toolbox to create a GUI.
I have an axes and two pushbuttons in my GUI.
When the first pushbutton is pressed, I want to run an m file (not a function) in MATLAB which generates data and puts it in workspace.
When the second pushbutton is pressed, I want to make use of two vectors from the workspace and plot in the axes in the GUI.
% --- First push button executes on button press in StartExperiment.
function StartExperiment_Callback(hObject, eventdata, handles)
% hObject handle to StartExperiment (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
m = getappdata(0,'str1');
st = strcmp(m,'Set up is ready for experiment');
generate_FRF; % M FILE that I want to run. It is NOT a function
p = 'press the load button';
set(handles.StatusBox, 'String', p);
setappdata(0, 'st_pass', st);
% Second push button
function LoadData_Callback(hObject, eventdata, handles)
% hObject handle to LoadData (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% axes(handles.plotFRF);
% plot(f, 20*log10(abs(txy))); % The above two lines are my attempt which ended in an error
plot(handles.plotFRF, f, 20*log10(abs(txy))); % this also ends in an error
The thing I do not comprehend is when I press the First push button I do not get an error message but then I would expect that the line 'generate_FRF' in the above code is executed which should make a lot of variables available for me in the workspace. I do not see this when I test my code.
And when I press the second push button the error message that I receive is 'Undefined variable f' which is understandable. If I can generate the plot with the same approach, by that i mean, executing a different m file altogether and then using values would be preferable. I am also flexible with the implementation, can you please suggest a way that works which is also easy to implement?
If more information is needed please do not hesitate to ask.
Thank you!
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps 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!