% disp(' sine_vrs.m ver 1.0 December 11, 2007'); disp(' by Tom Irvine Email: tomirvine@aol.com '); disp(' '); % clear f; clear fn; clear H; % disp(' '); disp(' Enter base excitation amplitude (G) '); G=input(' '); % disp(' '); disp(' Enter base excitation frequency '); f=input(' '); % disp(' '); disp(' Enter starting frequency (Hz)'); fs=input(' '); % disp(' Enter ending frequency (Hz)'); fend=input(' '); % disp(' '); disp(' Enter amplification factor '); Q=input(' '); disp(' '); % damp=1/(2*Q); % nt=2000; df=(fend-fs)/nt; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % figure(1) % clear a; clear H; clear fn; for(i=1:(nt+1)) fn(i)=(i-1)*df+fs; rho=f/fn(i); a=(1-rho)^2+(2*damp*rho)^2; a=1/a; a=a*(1+(2*damp*rho)^2); H(i)=sqrt(a); end H=H*G; % plot(fn,H) xlabel(' Natural Frequency (Hz) '); Ylabel(' Accel (G) '); out1=sprintf('SDOF Q=%g Response to: %g G base input at %g Hz',Q,G,f); title(out1); grid on; set(gca,'MinorGridLineStyle',':','GridLineStyle',':','XScale','log','YScale','log'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % disp(' '); qqqq=input(' Press Enter to view relative displacement '); % figure(2) % clear H; clear fn; for(i=1:(nt+1)) fn(i)=(i-1)*df+fs; a=(fn(i)^2-f^2)^2+(2*damp*f*fn(i))^2; a=sqrt(a); a=a*4*pi^2; H(i)=1/a; end H=H*386.*G; % plot(fn,H) xlabel(' Natural Frequency (Hz) '); Ylabel(' Relative Displacement (inch) '); out1=sprintf('SDOF Q=%g Response to: %g G base input at %g Hz',Q,G,f); title(out1); grid on; set(gca,'MinorGridLineStyle',':','GridLineStyle',':','XScale','log','YScale','log');