%For this script we assume w0=1.

minw=0.1;  maxw=10;                         %min and max freqs
w=logspace(log10(minw),log10(maxw),1000);   %omega values
z=[0.5 0.3 0.2 0.1 0.05];            %zeta values
c='crgyb';                                 %colors for plots


for i=1:length(z)
    m=-20*log10(sqrt((1-w.^2).^2+(2*z(i)*w).^2));    
        semilogx(w,m,c(i));
            hold on
    leg{i}=sprintf('\\zeta=%3.2g',z(i));
end


% %Uncomment this section for "exact" approximation
% for i=1:length(z)
%     wr=sqrt(1-2*z(i)^2);  mp=-20*log10(2*z(i)*sqrt(1-z(i)^2));
%     ww=[w(1) wr wr wr 1 w(end)];
%     mm=[0    0  mp 0  0 m(end)];
%     plot(wr,mp,[c(i) '*']);
%     semilogx(ww,mm,[c(i) ':'],'LineWidth',2);
% end
% title('Exact Magnitude (solid) and ''Exact'' Asymptotic Approximation');


%Uncomment this section for simpler approximation
for i=1:length(z)
    wr=1;  mp=20*log10(1/2/z(i));
    ww=[w(1) wr wr wr w(end)];
    mm=[0     0 mp 0  m(end)];
    plot(wr,mp,[c(i) 'o']);
    semilogx(ww,mm,[c(i) ':'],'LineWidth',2);
end
title('Exact Magnitude (solid) and Simpler Asymptotic Approximation');


xlabel('Frequency (\omega/\omega_0)');
ylabel('Magnitude (dB)');
legend(leg)
axis([minw maxw -40 20]);
hold off