필터 지우기
필터 지우기

Error :Input argument "handles" is undefined with the axes

조회 수: 4 (최근 30일)
Gova ReDDy
Gova ReDDy 2014년 3월 15일
댓글: Walter Roberson 2014년 3월 15일
Hello,
I tried to implement a simple GUI in MAtlab7.7 like the below
function varargout = start1(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @start1_OpeningFcn, ...
'gui_OutputFcn', @start1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
function start1_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
function varargout = start1_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
start=uicontrol('Style','pushbutton','String', 'start', 'Position',[20 400 50 20],'Callback',@startbutton_Callback);
Exit=uicontrol('Style','pushbutton','String', 'Exit', 'Position',[20 20 50 20],'Callback',@pushbutton1_Callback);
function pushbutton1_Callback(hObject, eventdata, handles)
display('Goodbye');
close(gcf);
function startbutton_Callback(hObject, eventdata, handles)
axes(handles.axes2);
plot(sin(0:0.1:10))
It is giving error as
??? Input argument "handles" is undefined.
Error in ==> start1>startbutton_Callback at 91
axes(handles.axes2);
??? Error while evaluating uicontrol Callback
  댓글 수: 2
Dishant Arora
Dishant Arora 2014년 3월 15일
function startbutton_Callback(...)
handles
See what it echos at command prompt. Does the handles structure have field named axes2. It might be possible that you have given a different tag to it.
per isakson
per isakson 2014년 3월 15일
Do the other buttons work as expected?

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

채택된 답변

Walter Roberson
Walter Roberson 2014년 3월 15일
Only the object and the event are automatically added as input arguments to a callback. If you want handles to be passed as well you need to arrange that. When you use GUIDE to create graphic objects, it automatically puts appropriate code as the callback.
In your situation, where you are using only a single figure, I would recommend removing handles from the argument list, leaving the uicontrol() the way it is, and adding the following as the first line of code in the callback:
handles = guidata(hObject);
  댓글 수: 5
Gova ReDDy
Gova ReDDy 2014년 3월 15일
yes,the file was created using GUIDE and the comments were removed so as to add the real code.
Can I know how to print(display) a value(500) on the image('logo.JPG') when a push button(start) is selected as shown
function startbutton_Callback(hObject, eventdata)
handles = guidata(hObject);
axes(handles.axes2);
imshow('logo.JPG');
a1=str2num('500');
How to set properties(like position,size.colour,..)of the number to be displayed on the image.
Walter Roberson
Walter Roberson 2014년 3월 15일
text() it into position.
If you do not have any existing plot then image() and imagesc() and imshow() use row and column counts as the x and y coordinates so use those for your x and y for text() purposes. Just watch out for whether (1,1) is at the top left or at the bottom left.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by