Output from handles instead of globals
Mostrar comentarios más antiguos
I have these three different functions that all relate to the GUI, one doing some stuff, the other one using the result, and the third using the result from the 2nd. I have tried to use globals for the results, but it is a mess, so i was wondering if it was possible to use handles or something like that to do it instead?
function openFile_Callback(hObject, eventdata, handles)
global im;
im = imread(myimage);
-
function analyzeImage_Callback(~, ~, ~)
global im
global dat
level = graythresh(im);
diff_im = im2bw(im,level);
area = sum(diff_im);
dat = [area];
-
function exportResults_Callback(hObject, eventdata, handles)
global dat
csvwrite('csvlist.dat',dat)
Respuesta aceptada
Más respuestas (1)
Matt Tearle
el 17 de Feb. de 2011
0 votos
If these functions all live in the same file, the simplest way to pass data around is to use nested functions. A nested function has access to its parent's workspace.
The other way is to use getappdata/setappdata to embed the data in the figure handle.
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!