Im using GUIDE to make a matlab GUI which does some video computation. Using the preview function I can preview the live video from my webcam and do some calculations.
In the MainGUI i use the: setappdata(hImage,'UpdatePreviewWindowFcn',mypreview_fcn); to get to a custom preview function which is:
function mypreview_fcn(obj,event,himage)
originalframe=peekdata(vidobj,1);
while isempty(originalframe)
originalframe=peekdata(vidobj,1);
end
if kk>=1
[LogResult,y,dist]=QueryArduino;
if LogResult==1
kk=kk+1;
results{kk,1}=originalframe;
results{kk,2}=measure1;
results{kk,3}=measure2;
results{kk,4}=measure3;
results{kk,5}=measure4;
results{kk,6}=measure5;
results{kk,7}=measure7;
offset=median([results{:,7}]);
offset=measure2-measure3;
end
end
set(himage,'CData',originalframe);
end
I would like to pass the result matrix to a table in the MainGUI How can I access the GUI table;
You could do it using getappdata to pass all the data you want inside MainGUI
and populate the table. Actually I don't understand why you would use setappdata
to call a function.
For instance, in the function mypreview_fcn
you coudl write something like this right before the end of the function:
setappdata(0,'MyData',results);
and then in MainGUI
use getappdata
:
TableData = getappdata(0,'MyData');
set(HandletoTable,'Data',TableData);
An alternative (and better approach I think) to getappdata
would be to assign an output argument to the function mypreview_fcn
so that when you call it from mainGUI
the variable results
is recognized inside mainGUI
and you can populate the table simply using
set(HandletoTable,'Data',results);
Is this what you meant?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.