Harmonic motion – phasors

%FIG04_09  produces Figure 4.9, rotating vectors of harmonic motion.
%       See book, Section 4.9. Harmonic motion – phasors.
%       The complete title of Figure 4.9 is `Displacement, velocity,
%       acceleration and integral of harmonic motion as rotating
%       vectors’.
T = 3;
omega = 2*pi/T;
t = 0.25;
A = 1;
y = A*exp(i*omega*t);         % displacement
v = i*omega*y;                % velocity
a = -omega^2*y;               % acceleration
I = y/(i*omega);              % integral
subplot(1, 2, 1)
y = [ 0 y ];
v = [ 0 v ];
a = [ 0 a ];
I = [ 0 I ];
plot(real(y),imag(y),real(v),imag(v),real(a),imag(a),real(I),imag(I)), grid
axis(‘square’), axis([ -5 5 -5 5 ])
title(‘Phasor diagram’)
xlabel(‘Real’)
ylabel(‘Imaginary’)
text(0.5, 0.5, ‘y’)
text(-0.5, 1, ‘v’)
text(-3, -1.5, ‘a’)
text(0.5, -0.5, ‘I’)
t = 0: 0.025: 3;
y = A*exp(i*omega*t);         % displacement
v = i*omega*y;                % velocity
a = -omega^2*y;               % acceleration
I = y/(i*omega);              % integral
subplot(1, 2, 2)
plot(t,imag(y),t,imag(v),t,imag(a),t,imag(I)), grid
axis(‘square’), axis([ 0 3 -5 5 ])
title(‘Time domain’)
text(t(10), imag(y(10)), ‘y’)
text(t(10), imag(v(10)), ‘v’)
text(t(14), imag(a(14)), ‘a’)
text(t(57), imag(I(57)), ‘I’)
xlabel(‘t’)