function polyplot(r,e,m)
% Funkcija POLYPLOT(r,e,m) izracuna koeficiente polinoma, podanega 
%   z njegovimi koeficienti, nakljucno perturbira koeficiente z 
%   majhnimi perturbacijami, izracuna nove korene in jih narise. 
%
% Argumenti:
%   r = vektor korenov polinoma
%   e = maksimalna relativna perturbacija vsakega koeficienta
%   m = stevilo ponovitev (koliko novih polinomov generiramo)
%
% Rezultat:
%   Slika perturbiranih korenov
%

% Bor Plestenjak
% Predelava 1.10.1995
%
% Matlab code polyplot.m for Math 221, Question 1.9
% Written by James Demmel, Aug 1995

p=poly(r);   % Generate polynomial coefficients
hold off 
clf   % Set up plot
for i=1:m,   % Generate m random polynomials
   p1=p.*(ones(size(p))+e*2*(rand(size(p))-.5));   %  Add random relative perturbation of at most e to each coefficient
   r1=roots(p1);   %  Compute roots
   plot(real(r1),imag(r1),'r.'), hold on,   %  Plot roots
end
hold off