Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.31 KB | None | 0 0
  1. function pole_zero_plot ( c, d )
  2. %UNTITLED Summary of this function goes here
  3. %   Detailed explanation goes here
  4. pay = fliplr(c);
  5. payda = fliplr(d);
  6.  
  7. zeros = roots(pay)
  8. zer = real(zeros);
  9. zei = imag(zeros);
  10.  
  11. poles = roots(payda)
  12. por = real(poles);
  13. poi = imag(zeros);
  14.  
  15. czeros = arrayfun(@(t)nnz(zeros==t),zeros);
  16. cpoles = arrayfun(@(t)nnz(poles==t),poles);
  17.  
  18.  
  19. kesisim = intersect (zeros,poles);
  20.  
  21. a=length(zeros);
  22. b=length(poles);
  23.  
  24.  
  25. axis([-2 2 -2 2]);
  26. axis equal
  27. hold on
  28.  
  29. th = 0:pi/250:2*pi;
  30. xunit = cos(th) ;
  31. yunit = sin(th) ;
  32. plot(xunit, yunit);
  33.  
  34. for i=1:a
  35.     if ismember(zeros(i),kesisim)
  36.        continue
  37.     end
  38.     if czeros(i)==1
  39.         plot(zer(i),zei(i),'O');
  40.     else
  41.         plot(zer(i),zei(i),'OO');
  42.     end
  43. end
  44.  
  45. for i=1:b
  46.     if ismember(zeros(i),kesisim)
  47.        continue
  48.     end
  49.     if czeros(i)==1
  50.         plot(por(i),poi(i),'X');
  51.     else
  52.         plot(por(i),poi(i),'XX');
  53.     end
  54. end
  55.  
  56.        
  57. if a == b
  58.     annotation('textbox',[0.2,0.8,0.1,0.1],'String','no poles or zeros at z =\infty');
  59. end
  60. if a < b
  61.     str = sprintf('%d poles at z=\\infty',(b-a));
  62.     annotation('textbox',[0.2,0.8,0.1,0.1],'String',str);
  63. end
  64. if a > b
  65.     str = sprintf('%d zeros at z=\\infty',(a-b));
  66.     annotation('textbox',[0.2,0.8,0.1,0.1],'String',str);
  67. end
  68. hold off
  69.  
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement