How to load a .mat file with a push button, calculate the data using my own functions and plot a figure in a GUI made in GUIDE.

조회 수: 5 (최근 30일)
Hi everyone,
I am very new at this with making GUIs. I have a .mat file (consisting of 4 separate variables) that I am uploading using a push button in a GUI and using the code:
function load_file_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to load_file_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
filename = uigetfile('*.mat');
handles.data = load(filename);
I now want to change the data in the .mat file with a few functions I have written before as .m files (which I of course can copy into the GUI .m file) and plot a figure using a different pushbutton. Can anyone please help me?
Thanks in advance!
  댓글 수: 3
Andreas Ingelström
Andreas Ingelström 2016년 7월 6일
편집: Andreas Ingelström 2016년 7월 6일
I have a GUI with three push buttons (one to load the .mat file, one to create one type of figure and one to create another type), two text fields were I would like to type in parameters to adjust the figures and finally the figure itself.
When I have loaded the .mat file I would like to be able to get hold of the four variables in it when I call for them in other callbacks and other functions I have to adjust the variables and finally plot the data.
I have attached an image of how I would like my GUI to look like.
Andreas Ingelström
Andreas Ingelström 2016년 7월 6일
편집: Andreas Ingelström 2016년 7월 6일
If I use guidata(hObject, handles) to update the handle and let's say my .mat file consists of the variables p, t, x and y. How can I be able to call for the p matrix in another callback, change it and the save it for further use? Will handles.data.p work?

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff Hayes
Geoff Hayes 2016년 7월 7일
Andreas - yes, if your mat file consists of the variables p, t, x, and y, then if your first pushbutton callback does
function load_file_pushbutton_Callback(hObject, eventdata, handles)
filename = uigetfile('*.mat');
handles.data = load(filename);
guidata(hObject,handles);
then you will be able to access these variables in any other callback through (for example)
handles.data.x

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by