Hi,
I have a problem with axes_GUI.
To solve it,I tried many ways which I have got from this
forum or others.And also I know that there are many similar
problem and their solution.Be sure that I have tried
them,but not get the exact solution.Pleae help me.
The problem is;
I made a simple GUI which includes two materials:an axes
and a push button.When I click the push button,I get the
pictures well.But I need to update them sometimes,so I need
to click the push button again,but have an error.
%%%%%%Error%%%%%%%%%%%
??? Error using ==> axes
Invalid object handle.
Error in ==> axse>pushbutton1_Callback at 82
axes(handles.axes1)
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> axse at 42
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.
%%%%%%Code%%%%%%%%%%%
function varargout = axse(varargin)
% AXSE M-file for axse.fig
% AXSE, by itself, creates a new AXSE or raises the
existing
% singleton*.
%
% H = AXSE returns the handle to a new AXSE or the
handle to
% the existing singleton*.
%
% AXSE('CALLBACK',hObject,eventData,handles,...) calls
the local
% function named CALLBACK in AXSE.M with the given
input arguments.
%
% AXSE('Property','Value',...) creates a new AXSE or
raises the
% existing singleton*. Starting from the left,
property value pairs are
% applied to the GUI before axse_OpeningFunction gets
called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to axse_OpeningFcn via
varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI
allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help axse
% Last Modified by GUIDE v2.5 28-Jan-2008 11:09:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @axse_OpeningFcn, ...
'gui_OutputFcn', @axse_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
% --- Executes just before axse is made visible.
function axse_OpeningFcn(hObject, eventdata, handles,
varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)
% varargin command line arguments to axse (see VARARGIN)
% Choose default command line output for axse
handles.output = hObject;
% UIWAIT makes axse wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the
command line.
function varargout = axse_OutputFcn(hObject, eventdata,
handles)
% varargout cell array for returning output args (see
VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% 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)
The problem is that in subplot, there may be several handles not a signle handle depending on which subwindow you are making your plot. So, there may be incroeect reference of the subplot handles which create your problem.
Thank you for your reply.
I have to use subplot,because when I used two axes to show
these two different picture,the axes width-height changes
and becomes bigger.I lost myself in the property editor of
axes,but could not solve it.
(Sorry for possible repeating in the message,I might be
confused it).
Thank you for reply.
I have to use subplot.Because,when I use two
axes,seperately,to show these two image.the axes width and
height changes and becomes bigger.So I used subplot.
"Hasan Alimli" <su.sayaci@hotmail.com> wrote in message
<fnks2j$grp$1@fred.mathworks.com>...
> Any idea,please?
Just a thought
Instead of using one axes and using a subplot function,
why dont you use 2 axes.
ex:
Drop down 2 axes from the guide menu on to your figure
Assuming the 2 axes are axes1 and axes2 respectively
In the pushbutton function use this;
axes(handles.axes1);%gives focus to first axes
imshow('image1.jpg');
drawnow;
axes(handles.axes2);%gives focus to second axes
imshow('image2.jpg');
drawnow;
"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<fnktdm$7h5$1@fred.mathworks.com>...
> "Hasan Alimli" <su.sayaci@hotmail.com> wrote in message
> <fnks2j$grp$1@fred.mathworks.com>...
> > Any idea,please?
>
> Just a thought
> Instead of using one axes and using a subplot function,
> why dont you use 2 axes.
> ex:
> Drop down 2 axes from the guide menu on to your figure
> Assuming the 2 axes are axes1 and axes2 respectively
> In the pushbutton function use this;
>
> axes(handles.axes1);%gives focus to first axes
> imshow('image1.jpg');
> drawnow;
> axes(handles.axes2);%gives focus to second axes
> imshow('image2.jpg');
> drawnow;
>
> HTH
> Vihang
>
Sorry did not read your other statements before posting.
If you are dealing with only one axes, just remove the
definition, axes(handles.axes1); from your Push Button
function.
You can declare the same in the opening fcn
HTH
Vihang
First of all thank you for reply,
I have to use "subplot".Because I have to use "linkaxes"
command,and it works only for figures which drawn
by "subplot".with two different axes,it doesn't work.
In addition,there are many problems or troubles similar
with mine.But difference is "subplot".Because also I know
that If I dont use subplot,it is OK.
Thank you for help,
It is solved!
*The problem was "subplot in GUI".
*The solution lies on the "panel",not "axes".
*Graphics/plots should be drawn into the "panel",not "axes".
*Put a panel with tag property "xyz".
*code is;
a1=subplot(1,2,1,'Parent',handles.xyz);
imshow(I)
a2=subplot(1,2,2,'Parent',handles.xyz);
imshow(Q)
*At the end of this part,"linkaxes" (which is the reason of
using "subplot" instead of "two different axes") comes.
linkaxes([a1 a2],'xy')
*with this code the plot/show area can be fixed with panel
sizes without complexity of properties of axes.
Thank you.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.