% DEMO:         QUADRATIC ROOTS
%
% Program:      rootdemo.m
% Written by:   
% For:          EE 311
%               Demo For Computer Lab 1
% Date:         5-31-2001
% Purpose:      This program computes and plots the roots 
%               of the quadratic equation s^2 + 2*xi*w0*z + w0^2
%               for w0=1 and xi in the range from 0 to 4 on the 
%               complex plane using the movie command       

clear all, hold off, clf reset, warning off
hold on
axis([-4 0 -1.5 1.5]);          % plot range is for x,y
axis('normal')
grid

set(gcf,'DoubleBuffer','on')    % Keep screen from blinking
for xi = 0:0.1:4
    r=roots([1 xi 1]);          % Find roots of s^2+2*xi*w0*z+w0^2
    s1 = r(1);                  % First root s1
    s2 = r(2);                  % Second root s2
    plot(real(s1),imag(s1),'xr',real(s2),imag(s2),'ob')
    pause(.02)                  % Simulate a movie
end
    
xlabel('Real Part')
ylabel('Imag Part')
title('Roots of s^2+ 2\xi\omega{_0}s + \omega{_0}^2, for \omega{_0}{^2} = 1')
figure(gcf)