필터 지우기
필터 지우기

Help with GUI file using Guide

조회 수: 1 (최근 30일)
aurc89
aurc89 2014년 5월 29일
댓글: aurc89 2014년 5월 30일
Hi, I have a question about a simple GUI file; the interface is like the one in the figure.
By clicking 'Load' I load a simple matrix, called M, and plot it in the graph; I call 'wavelength' and 'spectra' the rows and the columns of M, but this is not important. Then in the four 'Edit texts' I write the values of rows and columns that I want to eliminate from the matrix M. The problem is that, when I press 'Cut' to eliminate these values, the programs doesn't recognize M anymore! The question is: how can I call , in the function 'cut', the matrix M defined in the function 'load'?
Here is the Load function, where I define M.
function Load_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
direct='C:\Users\Aurelio Oriana\Desktop\';
c=299792458;
[nomefile,dir]=uigetfile([direct,'*CALIB.dat'],'Load Calibration file');
file=[dir,nomefile];
% From PP traces
M=load(file);
axes(handles.axes1);
pcolor(M); shading interp;
xlabel('Wavelength (pixel)');
ylabel('Number of spectra');

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 5월 29일
You can use the guidata command to save data to the handles structure. Note how in the above code, the comment for handles reads structure with handles and user data (see GUIDATA). So you can do something like this
function Load_Callback(hObject, eventdata, handles)
% etc. everything that you have above
% now save the M matrix to the handles structure
handles.M = M;
guidata(hObject,handles);
In the body of your Cut callback, the M matrix should be directly accessible from handles as handles.M.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by