如何将数据从一个gui matlab传输到另一个gui matlab的编辑框

时间:2016-09-14 15:27:44

标签: matlab user-interface

我在matlab中有2个guis,名为main和sub。我通过subgui中的按钮对图像进行一些计算,并希望将结果(handles.shhandles.sv)传送到主gui的编辑框,这些结果应该在编辑框中以单独的行显示。我使用了setappdatagetappdata,但它不起作用,并且它没有显示任何或更多可能我犯了错误。

编辑主gui的回调

function edithistory_Callback(hObject, eventdata, handles)
% hObject    handle to edithistory (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.sh =  getappdata(0,'horizontal');
set(hObject,'String',num2str(handles.sh));
handles.sh =  getappdata(0,'vertical');
set(hObject,'String',num2str(handles.sv));

subgui的按钮回调

Bw    =  im2bw(handles.D);

s     =  regionprops(Bw, handles.D, 'Centroid');
handles.sx  =  round(s.Centroid(1));
handles.sy  =  round(s.Centroid(2));
handles.roi =  handles.roi/2;
i     =  (handles.sx-((handles.roi)-1)):(handles.sx+ handles.roi);
j     =  (handles.sy-((handles.roi)-1)):(handles.sy+ handles.roi);
  ROI   =  (handles.D(i,j));     
      ROI   =  (2^16)-ROI;
      avg   =  sum(ROI(:))/((2*handles.roi).^2);
     profileh1 = (handles.D(handles.sx,:));
  profileh  = (2^16-profileh1);
 profileh(1)=  profileh(2);
FieldSizeh  =  profileh(profileh>=avg*0.5);
FieldSizeh(:)  =avg;
 handles.sh = (size(FieldSizeh,2)*0.25);
 setappdata(0,'horizontal',handles.sh);
profilev1   =  handles.D(:,handles.sy);
  profilev  = (2^16-profilev1);
 profilev(1)=  profilev(2);    
FieldSizev  =  profilev(profilev>=avg*0.5);
FieldSizev(:)=avg;
 handles.sv = (size(FieldSizev,1)*0.25);
 setappdata(0,'vertical',handles.sv);

0 个答案:

没有答案