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