Jump to content

can someone help with this function in matlab?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Reza

Reza

    Newbie

  • Members
  • Pip
  • 2 posts
i've wrote this m-file but it has some errors.
function dpzplot(b,a) 
% dpzplot(b,a) 
% Plots the pole-zero diagram for the discrete-time system function 
% H(z)=b(z)/a(z) defined by numerator and denominator polynomials b and a. 
la=length(a); 
lb=length(b); 
if (la>lb), 
b= [b zeros(1,la-lb)] ; 
elseif (lb>la), 
a= [a zeros(1,lb-la)] ; 
end 
ps = roots(a) ; 
zs = roots(b) ; 
mx = max(abs([ps' zs' .95]))+0.05; 
clf 
axis ([-mx mx -mx mx]); 
axis('equal'); 
hold on 
w=[0:0.01:2*pi]; 
plot(cos(w),sin(w),'.'); 
plot([-mx mx],[0 0]); 
plot([0 0],[-mx mx]); 
text(0.1,1.1,'Im','sc'); 
text(l.l,0.1,'Re','sc'); 
plot(real(ps),imag(ps),'x'); 
plot(real(zs),imag(zs),'o'); 
numz=sum(abs(zs)==0); 
nump=sum(abs(ps)==0); 
if numz>l, 
text(-0.1,-0.1,num2str(numz)); 
elseif nump>l, 
text(-0.1,-0.1,num2str(nump)); 
end 
hold off ;


:irritated:

error:when running m-file:

??? Input argument "a" is undefined.

Error in ==> dpzplot at 5
la=length(a);

what should i do?

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
Remember to use code-tags!

#3
Reza

Reza

    Newbie

  • Members
  • Pip
  • 2 posts

v0id said:

Remember to use code-tags!

tanx for answer,i forgot to say i'm a beginner and tanx for code-tag u add.

but what should be changed that i could run the program