Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: GUi axes

Subject: GUi axes

From: Hasan Alimli

Date: 28 Jan, 2008 09:33:01

Message: 1 of 11

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;
 
% Update handles structure
guidata(hObject, handles);
 
% 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)
 
axes(handles.axes1)
 
I =imread('41.bmp');
Q =imread('resim.bmp');

subplot(2,2,3)
imshow(I);
title('Input')
subplot(2,2,4)
imshow(Q);
title('Output')

Subject: Re: GUi axes

From: Hasan Alimli

Date: 28 Jan, 2008 11:30:44

Message: 2 of 11

I tried it without "subplot",it is OK!
What is the problem with "subplot" in the GUI applications?

Subject: Re: GUi axes

From: Yumnam Kirani Singh

Date: 28 Jan, 2008 11:46:46

Message: 3 of 11

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.

Subject: Re: GUi axes

From: Hasan Alimli

Date: 28 Jan, 2008 12:19:02

Message: 4 of 11

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.

Subject: Re: GUi axes

From: Hasan Alimli

Date: 28 Jan, 2008 12:22:02

Message: 5 of 11

(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.

Subject: Re: GUi axes

From: Hasan Alimli

Date: 28 Jan, 2008 12:24:02

Message: 6 of 11

And what about closing/cleaning the axes,the re-show
again,when I click the pusbutton seconly?If so,how can I do
it?

Subject: Re: GUi axes

From: Hasan Alimli

Date: 28 Jan, 2008 15:24:03

Message: 7 of 11

Any idea,please?

Subject: Re: GUi axes

From: Vihang Patil

Date: 28 Jan, 2008 15:47:02

Message: 8 of 11

"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

Subject: Re: GUi axes

From: Vihang Patil

Date: 28 Jan, 2008 16:02:02

Message: 9 of 11

"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

Subject: Re: GUi axes

From: Hasan Alimli

Date: 29 Jan, 2008 06:23:02

Message: 10 of 11

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.

Subject: Re: GUi axes

From: Hasan Alimli

Date: 30 Jan, 2008 06:25:05

Message: 11 of 11

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.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
rake receiver tag peter mani 03 Feb, 2008 05:36:41
gui Hasan Alimli 30 Jan, 2008 01:25:01
subplot Hasan Alimli 30 Jan, 2008 01:25:01
axes Hasan Alimli 30 Jan, 2008 01:25:01
size Hasan Alimli 30 Jan, 2008 01:25:01
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

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.
Related Topics