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:26:03 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 36
Message-ID: <h79egr$j33$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 1251491163 19555 172.30.248.37 (28 Aug 2009 20:26:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 28 Aug 2009 20:26:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: news.mathworks.com comp.soft-sys.matlab:566861


I would be willing to bet that you set the callback to the pushbutton before S.ax1 was created.  When you are programming by storing all info in a structure S, you need to assign callbacks that take S as an argument AFTER all needed fields of S have been set.  See the added line below.



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]);

set(push,'callback',{@push_call,S})    % ADDED AFTER S.ax1, S.ax2 are created!!!!

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