% resonance.m
% simple code to show how amplitude varies with beta and omega.  (Fixed
% omega0)

omega0=10;
omega=[.15:0.15:20];
beta=[0:.05:1.5];
for i=1:max(size(omega))
    for j=1:max(size(beta))
        A(i,j)=1./((omega0*omega0-omega(i)*omega(i))^2+4*beta(j)*beta(j)*omega(i)*omega(i));
    end
end

figure
surf(beta,omega,log(sqrt(A)))
xlabel('\beta','FontSize',24)
ylabel('\omega','FontSize',24)
zlabel('ln (A)','FontSize',24)
title('Resonant Amplitude.  \omega_\circ = 10, f_\circ = 1','FontSize',24)
view([47,32])

omega=[.1:0.01:20];
beta=[0:.01:1.5];

for i=1:max(size(omega))
    for j=1:max(size(beta))
        A(i,j)=1./((omega0*omega0-omega(i)*omega(i))^2+4*beta(j)*beta(j)*omega(i)*omega(i));
    end
end


figure
subplot(3,1,1)
plot(omega,A(:,1),'k','LineWidth',4)
xlabel('\omega','FontSize',24)
ylabel('A','FontSize',24)
grid on
title(sprintf('Resonant Amplitude. beta = %1.3f',beta(1)),'FontSize',24)
subplot(3,1,2)
plot(omega,A(:,floor(max(size(beta))/2)),'k','LineWidth',4)
xlabel('\omega','FontSize',24)
ylabel('A','FontSize',24)
grid on
title(sprintf('beta = %1.3f',beta(floor(max(size(beta))/2))),'FontSize',24)
subplot(3,1,3)
plot(omega,A(:,end),'k','LineWidth',4)
xlabel('\omega','FontSize',24)
ylabel('A','FontSize',24)
grid on
title(sprintf('beta = %1.3f',beta(max(size(beta)))),'FontSize',24)