Help with GUI file using Guide
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
aurc89
el 29 de Mayo de 2014
Comentada: aurc89
el 30 de Mayo de 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');
0 comentarios
Respuesta aceptada
Geoff Hayes
el 29 de Mayo de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!