% DEMO          ROTATING PHASOR DEMO
%
% Program:      rotating_phasor.m
% Written by:   Michael Buehner
% For:          EE 311
%               Demo For Computer Lab 2
% Date:         8-4-2001
% Purpose:      To demonstrate a rotating phasor
clear all, close all
j=sqrt(-1);

A=10;                           % Amplitude
f=1000;                         % Frequency (Hz)
phase=-pi/4;                    % Initial phase

w=2*pi*f;                       % Radian frequency (rad/sec)
phasor=A*exp(j*phase);          % Initial phasor

t=0:pi/100000:pi/2000;

rot_phasor=exp(j*w*t)*phasor;   % Rotating phasor

set(gcf,'DoubleBuffer','on')    % Keep screen from blinking
compass(phasor);
hold on
title('Rotating Phasor Demo')
pause(.1)

for i=1:length(t)
    compass(rot_phasor(i),'b')
    pause(.1)                   % Simulate a movie
    compass(rot_phasor(i),'w')
end
compass(rot_phasor(i),'b')      % Plot final position of phasor
compass(phasor,'g')             % Plot the original phasor
figure(gcf)