from Vibration Response Spectrum by Tom Irvine
This program calculates the VRS for a base input PSD.

VRS.m
disp(' ')
disp(' vrs.m   ver 1.1   December 20, 2003')
disp(' by Tom Irvine   Email: tomirvine@aol.com')
disp(' ')
disp(' This program calculates the vibration response spectrum')
disp(' of an acceleration power spectral density, which is pre-loaded into Matlab.')
disp(' ')
disp(' The power spectral density may vary arbitrarily with frequency. ')
disp(' The input file must have two columns: frequency(Hz) & accel(G^2/Hz)')
disp(' ')
%
clear f;
clear a;
clear s;
%
THF = input(' Enter the input PSD filename:  ');
%
f=THF(:,1);
a=THF(:,2);
%
MAX = 5000;
tpi=2.*pi;
%
idamp=input(' Enter damping format:  1= damping ratio   2= Q  ');	
%
disp(' ')
if(idamp==1)
    damp=input(' Enter damping ratio (typically 0.05) ');
else
    Q=input(' Enter the amplification factor (typically Q=10) ');
    damp=1./(2.*Q);
end
%
n=length(f);
%
[s,grms]=calculate_PSD_slopes(f,a);
out5 = sprintf('\n Input PSD Overall Level = %10.3f \n',grms);
disp(out5);
%
df=1.;
%
[fi,ai]=interpolate_PSD(f,a,s,df);
%
[fn,a_vrs,rd_vrs]=vrs_engine(fi,ai,damp,df);
%
disp(' ')
Q=1./(2.*damp);
disp(' Plot acceleration VRS ?');
choice = input(' 1=yes  2= no  ');
%
if(choice==1)
    at = sprintf(' Acceleration Vibration Response Spectrum Q=%g ',Q);
    ay = sprintf(' Accel (GRMS)');
    Q2=AVRS_plot(fn,fi,a_vrs,damp,ay,at);
end
%
disp(' ')
disp(' Plot relative displacement VRS ?');
choice = input(' 1=yes  2= no  ');
if(choice==1)
    at = sprintf(' Relative Displacement Vibration Response Spectrum Q=%g ',Q);
    ay = sprintf(' Rel Disp (inch RMS)');
    Q2=AVRS_plot(fn,fi,rd_vrs,damp,ay,at);   
end
%
disp(' ')
disp(' Write acceleration VRS to text file? ')
choice=input(' 1=yes   2=no  ' );
disp(' ')
%
if choice == 1 
   disp(' Enter output filename ');
   VRS_filename = input(' ','s');
   disp(' ')
   disp(' Output units:  fn(Hz)  &  Accel (GRMS) '); 
   jnum = length(fn);
   fid = fopen(VRS_filename,'w');
   for j=1:jnum
        fprintf(fid,'%7.2f %11.4g \n',fn(j),a_vrs(j));
   end
   fclose(fid);
end
%
disp(' ')
disp(' Write relative displacement VRS to text file? ')
choice=input(' 1=yes   2=no  ' );
disp(' ')
if choice == 1 
   disp(' Enter output filename ');
   VRS_filename = input(' ','s');
   disp(' ')
   disp(' Output units:  fn(Hz)  &  Rel Disp (inch RMS) ');
%
   jnum = length(fn);
   fid = fopen(VRS_filename,'w');
   for j=1:jnum
        fprintf(fid,'%7.2f %11.4g \n',fn(j),rd_vrs(j));
   end
   fclose(fid);
end
%

Contact us at files@mathworks.com