필터 지우기
필터 지우기

How to load .mat into GUI

조회 수: 2 (최근 30일)
Edward P
Edward P 2011년 11월 8일
Hi everyone, It occurs an error that i can't understand why.
%load button
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname] = uigetfile({'*.mat';'*.*'}, 'Load');
file_load = fullfile(pathname,filename);
set(handles.pushbutton1,'enable','on');
load(file_load);
imshow(handles.E,'Parent',handles.axes3);
imshow(handles.D,'Parent',handles.axes4);
guidata(hObject, handles);
the error is:
??? Error using ==> imshow>validateParent at 307
HAX must be a valid axes handle.
Error in ==> imshow at 221
validateParent(specific_args.Parent)
Error in ==> tent>pushbutton3_Callback at 102
imshow(handles.E,'Parent',handles.axes3);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> tent at 43
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)tent('pushbutton3_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
What i have made wrong? I believe that my workspace is successfully loaded.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 11월 9일
Hi Edward,
hmm, you load the handles? That will probably fail because each time you start your GUI, handles.axes3 and handles.axes4 will be different. I would do the following instead
im = load(file_load);
handles.D = im.handles.D;
handles.E = im.handles.E;
imshow(handles.E,'Parent',handles.axes3);
imshow(handles.D,'Parent',handles.axes4);
This way you leave your (other) handles untouched ...
Titus
  댓글 수: 1
Edward P
Edward P 2011년 11월 9일
You were right! thanks! It really works now!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Titus Edelhofer
Titus Edelhofer 2011년 11월 8일
Hi,
hmm, I am wondering why it is
imshow(handles.E,'Parent',handles.axes3);
in the error message but
imshow(handles.image1,'Parent',handles.axes3);
in the code. But apart from that: what variable do you read from the .mat file? And where do you use it? I can't see it in the code ...
Titus
  댓글 수: 1
Edward P
Edward P 2011년 11월 8일
My fault! i used image1 to make easier to understand.
The point is:load some images (E and D) that i've once invoked to my program, and plot those images on axes3 and axes4. This plot is correct because i've have already used this code.

댓글을 달려면 로그인하십시오.


Naz
Naz 2011년 11월 8일
handles.E=load(file_load);
  댓글 수: 2
Edward P
Edward P 2011년 11월 8일
load(file_load), loads my handles already.
Naz
Naz 2011년 11월 8일
hm... this should work. And you are sure you have your axes tagged as axes3 and axes4?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by