I am trying to use guide and could use some help with functions in 2014a
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a function "imgImport" which passes these output "im, hdr,old, datafile, hdrfile" but I can not grab this data in the next function. I noticed it is not propagating the data to the work space, and found that it is stored in the GUI. I have two buttons one to grab the image the second to crop the image; here is the function as I tried.
function pushbutton1_Callback(hObject, eventdata, handles)
%disp('imgImport')
[im, hdr,old, datafile, hdrfile]= imgImport;
% 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)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
[imgVIS, imgSWIR, rect,img,rowend, rowstart, colend, colstart]= cropping(im, hdr);
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
How do I get one button to grab outputs from the other buttons data.
댓글 수: 0
채택된 답변
Geoff Hayes
2014년 6월 2일
You can use the handles structure with the guidata function to store/save user data to the structure. Try something like this
function pushbutton1_Callback(hObject, eventdata, handles)
% call your script
[im, hdr,old, datafile, hdrfile]= imgImport;
% assign the user data to the structure
handles.im = im;
handles.hdr = hdr;
% save the data
guidata(hObject,handles);
Now in your other button callback, just access the data directly from the handles structure:
function pushbutton2_Callback(hObject, eventdata, handles)
[imgVIS, imgSWIR, rect,img,rowend, rowstart, colend, colstart] = …
cropping(handles.im, handles.hdr);
Try the above and see if that does what you wish.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!