Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Handle 2 axes at a time...
Date: Fri, 28 Aug 2009 20:17:19 +0000 (UTC)
Organization: Georgia Institute of Technology
Lines: 50
Message-ID: <h79e0f$g4r$1@fred.mathworks.com>
References: <0bafa2ba-ed9b-4487-a6a2-a1aaa64b54da@d15g2000prc.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1251490639 16539 172.30.248.37 (28 Aug 2009 20:17:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 28 Aug 2009 20:17:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 939004
Xref: news.mathworks.com comp.soft-sys.matlab:566859


JDK_3 <jaydu1904@gmail.com> wrote in message <0bafa2ba-ed9b-4487-a6a2-a1aaa64b54da@d15g2000prc.googlegroups.com>...
> Hi guys,
> I am trying to make a GUI in MATLAB that plots two graphs(say a sine
> wave  and 2nd is its shifted version).
> But I am unable to plot them differently on two different axes.
> 
> Here is the piece of code:
> 
> S.ax1 = axes('xlim',[0 1],'ylim',[0 1]);
> %define axes1
> set(S.ax1,'unit','pix','position',[50 325 570 250]);
> 
> S.ax2 = axes('xlim',[0 1],'ylim',[0 1]);
> %define axes2
> set(S.ax2,'unit','pix','position',[50 60 570 250]);
> 
> 
> function [] = push_call(varargin)
> 
> S = varargin{3};
> P = get(S.pop,'val');             %get value of popup menu 'pop'
> 
> switch P
>     case 1
>        axes(S.ax1);
>                 x = -5:0.01:5;
>                 y = sin(x);
>                 plot(x,y);
> 
>         switch findobj(get
> (S.select_option,'selectedobject'))                    %get selected
> radio button
>             case S.advance
>                 axes(S.ax2);
>                 x = -5:0.01:5;
>                 y = sin(x+2);
>                 plot(x,y);
>         end
> end
> 
> 
> 
> I am getting an error
> 
> >Reference to non-existent field 'ax1'.
> >Error in ==> plot_1>push_call at 67   axes(S.ax1);
> 
> 

After defining S.ax1 and S.ax2 in your initial code, do you call guidata to store these values? You need to do that. Something like guidata(gcf,S).