Clear Filters
Clear Filters

how i can fix this axes error ?

1 view (last 30 days)
Husain
Husain on 21 May 2013
Hi
i have popup menu and two axes, one axes show image and another one two show plot, when i write number in edit text than press push button show plot in axes and i have more than one plot but found error when i select next one my code is :
val = get(handles.popup,'Value'); %get currently selected option from menu
str = get(handles.popup,'string');
if val==1
axes(handles.plotaxes);
a = str2num(get(handles.edit1,'String'));
b = str2num(get(handles.edit2,'String'));
n1=length (a)
n2=length (b)
x=0:1:n1-1;
subplot (2, 2, 1), stem(x, a);
title ('INPUT SEQUENCE1');
xlabel ('---->n');
ylabel ('---->a (n)');
y=0:1:n2-1;
subplot (2, 2, 2), stem(y, b);
title ('INPUT SEQUENCE2');
xlabel ('---->n');
ylabel('---->b(n)');
c=conv (a, b);
n3=0:1:n1+n2-2;
subplot (2, 1, 2), stem (n3, c);
title ('CONVOLUTION OF TWO SEQUENCES');
xlabel ('---->n');
ylabel ('---->c (n)')
elseif val==2
a = str2num(get(handles.edit1,'String'));
b = str2num(get(handles.edit2,'String'));
n1=length (a);
n2=length (b);
n3=n1-n2;
N=max (n1, n2);
if (n3>0);
b= b, zeros (1, n1-n2);
n2=length (b);
else
a= a, zeros (1, N-n1);
n1=length (a);
end
k=max (n1, n2);
a=a'; b=b'; c=b;
for i=1: k-1
b=circshift (b, 1);
c=[c, b];
end;
disp(c);
z=c*a;
disp ('z=')
disp (z)
subplot (2, 2, 1);
stem (a,'filled');
title ('INPUT SEQUENCE1');
xlabel ('---->n');
ylabel ('---->Amplitude');
subplot (2, 2, 2);
stem (b,'filled');
title ('INPUT SEQUENCE2');
xlabel ('---->n');
ylabel ('---->Amplitude');
subplot (2, 1, 2);
stem (z,'filled');
title ('CONVOLUTION OF TWO SEQUENCES');
xlabel ('---->n');
ylabel ('---->Amplitude');
end;
this is the error:
Error using axes
Invalid object handle
Error in dspgui>plotbutton_Callback (line 201)
axes(handles.plotaxes);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in dspgui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)dspgui('plotbutton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback

Answers (2)

David Sanchez
David Sanchez on 21 May 2013
You are not declaring
axes(handles.plotaxes);
after
if val==2

Walter Roberson
Walter Roberson on 21 May 2013
subplot() deletes any existing axes that the subplot would cover. So your subplot(2,2,1) deletes the existing axis handles.plotaxes
subplot() applies to figure (or uipanels), not to axes. I don't think you can have axes objects that are children of other axes objects (but maybe it is possible through hggroup, I would have to research.)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!