%% Example 3
% Assume \omega =2\pi rad/s (so period T=1 s). Plot the response e^{-\sigma t} \cos \left(\omega t\right) for Q=20 and Q=10.
%% Solution to Example 3
% Given that
% Q=\frac{1}{2}\sqrt{\frac{\omega^2 +\sigma^2 }{\sigma^2 }}
% it is relatively easy to show that
% $$\sigma = \frac{\omega}{\sqrt{4Q^2 - 1}}$$
% So to plot this:

omega = 2*pi;
t = linspace(0,30,1000);
Q = 20;
sigma = omega/sqrt(4*Q^2 - 1);
subplot(211)
plot(t,exp(-sigma*t).*cos(omega*t)),title('Q = 20'),grid on
Q = 10;
sigma = omega/sqrt(4*Q^2 - 1);
subplot(212)
plot(t,exp(-sigma*t).*cos(omega*t)),title('Q = 10'), grid on

%