Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pole_zero_plot ( c, d )
- %UNTITLED Summary of this function goes here
- % Detailed explanation goes here
- pay = fliplr(c);
- payda = fliplr(d);
- zeros = roots(pay)
- zer = real(zeros);
- zei = imag(zeros);
- poles = roots(payda)
- por = real(poles);
- poi = imag(zeros);
- czeros = arrayfun(@(t)nnz(zeros==t),zeros);
- cpoles = arrayfun(@(t)nnz(poles==t),poles);
- kesisim = intersect (zeros,poles);
- a=length(zeros);
- b=length(poles);
- axis([-2 2 -2 2]);
- axis equal
- hold on
- th = 0:pi/250:2*pi;
- xunit = cos(th) ;
- yunit = sin(th) ;
- plot(xunit, yunit);
- for i=1:a
- if ismember(zeros(i),kesisim)
- continue
- end
- if czeros(i)==1
- plot(zer(i),zei(i),'O');
- else
- plot(zer(i),zei(i),'OO');
- end
- end
- for i=1:b
- if ismember(zeros(i),kesisim)
- continue
- end
- if czeros(i)==1
- plot(por(i),poi(i),'X');
- else
- plot(por(i),poi(i),'XX');
- end
- end
- if a == b
- annotation('textbox',[0.2,0.8,0.1,0.1],'String','no poles or zeros at z =\infty');
- end
- if a < b
- str = sprintf('%d poles at z=\\infty',(b-a));
- annotation('textbox',[0.2,0.8,0.1,0.1],'String',str);
- end
- if a > b
- str = sprintf('%d zeros at z=\\infty',(a-b));
- annotation('textbox',[0.2,0.8,0.1,0.1],'String',str);
- end
- hold off
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement