Help with GUI file using Guide

1 view (last 30 days)
aurc89
aurc89 on 29 May 2014
Commented: aurc89 on 30 May 2014
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');

Accepted Answer

Geoff Hayes
Geoff Hayes on 29 May 2014
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.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!