function[damp,rd_trans_x,rd_trans_y,rd_trans_z,trans_x,trans_y,trans_z,...
  power_trans_x,power_trans_y,power_trans_z,rd_power_trans_x,rd_power_trans_y,rd_power_trans_z,fig_num]...
  =iso_frf(mass,ModeShapes,omegan,fig_num)
%
write_details=2;
%
%
MST=ModeShapes';
%
sz=size(ModeShapes);
dof=(sz(1));
num=dof;
%
disp(' Select modal damping input method ');
disp('  1=uniform damping for all modes ');
disp('  2=damping vector ');
idm=input(' ');
%
disp(' ');
if(idm==1)
   disp(' Enter damping ratio ');
   dampr=input(' ');
   damp(1:num)=dampr;
else
   disp(' Modal Damping Vector ');
%
   if(file_choice==1)
        damp = input(' Enter the vector:  ');
   end
   if(file_choice==2)
        [filename, pathname] = uigetfile('*.*');
        xfile = fullfile(pathname, filename);
%        
        damp = xlsread(xfile);
%         
   end
end
%
df=0.2;
fmax=2000;
np=fmax/df;
freq=linspace(df,np*df,np);
%
sz=size(freq);
if(sz(2)>sz(1))
    freq=freq';
end
%
omega=2*pi*freq;
om2=omega.^2;
%
omn2=omegan.^2;
%
two_damp_omegan=zeros(6,1);
%
for i=1:dof 
    two_damp_omegan(i)=2*damp(i)*omegan(i);
end
%
out1=sprintf('\n number of dofs =%d \n',num);
disp(out1);
%
%
%  Being main loop ********************************************************
%
%  np=number of excitation frequencies
%
J=sqrt(-1);
%
for iaxis=1:3   
%
     rd=zeros(np,dof);
    acc=zeros(np,dof);
%
    for i=1:np 
%
         n=zeros(6,1);
        na=zeros(6,1);
%
        for j=1:dof
           A=-MST(j,iaxis)*mass;
           den= (omn2(j)-om2(i)) + J*(two_damp_omegan(j)*omega(i));
           n(j)=A/den;
        end
        na=-om2(i)*n;
%
         rd(i,:)=ModeShapes*n;
        acc(i,:)=ModeShapes*na;
        acc(i,iaxis)=acc(i,iaxis)+1;  
%
    end 
%
     rd=abs(rd);
    acc=abs(acc);
%
     rd_trans=[freq 386*rd];
    acc_trans=[freq acc];
%
    if(iaxis==1)
        figure(fig_num);
        fig_num=fig_num+1;
        title_string=' Accel Transmissibility Magnitude  X-axis Excitation';
    end
    if(iaxis==2)
        figure(fig_num);
        fig_num=fig_num+1;
        title_string=' Accel Transmissibility Magnitude  Y-axis Excitation';      
    end
    if(iaxis==3)
        figure(fig_num);
        fig_num=fig_num+1; 
        title_string=' Accel Transmissibility Magnitude  Z-axis Excitation';        
    end  
 %
    sz=size(acc);
    if(write_details==1)
        disp(' ');
        out1=sprintf(' size(acc) %d %d  ',sz(1),sz(2));
        disp(out1);
    end
%
    if(write_details==1)
        sz=size(acc_trans);
        out1=sprintf(' size(acc_trans) %d %d  ',sz(1),sz(2));
        disp(out1);   
    end
 %
    if(iaxis==1)
        trans_x=acc_trans;
        plot(freq,trans_x(:,2),freq,trans_x(:,3),freq,trans_x(:,4));
    end
    if(iaxis==2)
        trans_y=acc_trans; 
        plot(freq,trans_y(:,2),freq,trans_y(:,3),freq,trans_y(:,4));        
    end
    if(iaxis==3)
        trans_z=acc_trans;
        plot(freq,trans_z(:,2),freq,trans_z(:,3),freq,trans_z(:,4));        
    end  
 %
    legend ('X-axis Response','Y-axis Response','Z-axis Response');   
%
    fmin=1;
    fmax=2000;
    ymax2=max(acc_trans(:,2));
    ymax3=max(acc_trans(:,3));
    ymax4=max(acc_trans(:,4));
    ymax=ymax2;
    if(ymax<ymax3)
        ymax=ymax3;
    end
    if(ymax<ymax4)
        ymax=ymax4;
    end
 %
    for i=-10:10
        if(ymax<10^i)
            ymax=10^i;
            break;
        end
    end
 %   
    ymin=ymax*0.0001;
    axis([fmin,fmax,ymin,ymax]);
    set(gca,'MinorGridLineStyle','none','GridLineStyle',':','XScale','log','YScale','log'); 
    grid on;
    title(title_string);
    xlabel(' Frequency (Hz) ');
    ylabel(' Trans (G/G) ');
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
    if(iaxis==1)
        figure(fig_num);
        fig_num=fig_num+1;
        title_string=' Rel Disp Transmissibility Magnitude  X-axis Excitation';
    end
    if(iaxis==2)
        figure(fig_num);
        fig_num=fig_num+1;   
        title_string=' Rel Disp Transmissibility Magnitude  Y-axis Excitation';      
    end
    if(iaxis==3)
        figure(fig_num);
        fig_num=fig_num+1;
        title_string=' Rel Disp Transmissibility Magnitude  Z-axis Excitation';        
    end  
%
    if(iaxis==1)
        rd_trans_x=rd_trans;
        plot(freq,rd_trans_x(:,2),freq,rd_trans_x(:,3),freq,rd_trans_x(:,4));
    end
    if(iaxis==2)
        rd_trans_y=rd_trans; 
        plot(freq,rd_trans_y(:,2),freq,rd_trans_y(:,3),freq,rd_trans_y(:,4));        
    end
    if(iaxis==3)
        rd_trans_z=rd_trans;
        plot(freq,rd_trans_z(:,2),freq,rd_trans_z(:,3),freq,rd_trans_z(:,4));        
    end  
 %
    legend ('X-axis Response','Y-axis Response','Z-axis Response');   
%
    fmin=1;
    fmax=2000;
%
    ymax2=max(rd_trans(:,2));
    ymax3=max(rd_trans(:,3));
    ymax4=max(rd_trans(:,4));
    ymax=ymax2;
    if(ymax<ymax3)
        ymax=ymax3;
    end
    if(ymax<ymax4)
        ymax=ymax4;
    end
%
    for i=-10:10
        if(ymax<10^i)
            ymax=10^i;
            break;
        end
    end
 %   
    ymin=ymax*0.0001;
    axis([fmin,fmax,ymin,ymax]);
    set(gca,'MinorGridLineStyle','none','GridLineStyle',':','XScale','log','YScale','log'); 
    grid on;
    title(title_string);
    xlabel(' Frequency (Hz) ');
    ylabel(' Trans (in/G) ');
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
end
%
disp(' ');
disp(' View plots.  Note that some curves may be below lower plot amplitude limit. ');
%
size(trans_x)
%
    power_trans_x(:,1)=trans_x(:,1);
    power_trans_y(:,1)=trans_y(:,1);
    power_trans_z(:,1)=trans_z(:,1);    
%
    rd_power_trans_x(:,1)=rd_trans_x(:,1);
    rd_power_trans_y(:,1)=rd_trans_y(:,1);
    rd_power_trans_z(:,1)=rd_trans_z(:,1);   
%
    clear length;
    nnn=length(trans_x(:,1));
%
    for i=1:nnn
        for j=2:7
           power_trans_x(i,j)=(trans_x(i,j))^2; 
           power_trans_y(i,j)=(trans_y(i,j))^2;    
           power_trans_z(i,j)=(trans_z(i,j))^2;     
 %
           rd_power_trans_x(i,j)=(rd_trans_x(i,j))^2; 
           rd_power_trans_y(i,j)=(rd_trans_y(i,j))^2;    
           rd_power_trans_z(i,j)=(rd_trans_z(i,j))^2;   
        end
    end
%
    disp(' ');
    disp(' *** Acceleration Transmissibility Output Files *** ');
    disp(' ');
    disp('   Output File Columns:  ');
    disp('     Freq    X     Y     Z     alpha       beta        theta      ');
    disp('     (Hz)  (G/G) (G/G) (G/G)  (rad/s^2/G) (rad/s^2/G) (rad/s^2/G) ');
%
    disp(' ');
    disp('    Output Filenames:  ');
    disp('      trans_x  -  X-axis input ')
    disp('      trans_y  -  Y-axis input ')    
    disp('      trans_z  -  Z-axis input ')
%
    disp(' ');
    disp(' *** Power Transmissibility Output Files *** ');
    disp(' ');
    disp('   Output File Columns:  ');
    disp('     Freq      X         Y         Z       alpha            beta  theta ');
    disp('     (Hz)  (G^2/G^2) (G^2/G^2) (G^2/G^2) ((rad/s^2)^2/G^2)    <-   <-   ');
%
    disp(' ');
    disp('    Acceleration Output Filenames: ');    
    disp('      power_trans_x  -  X-axis input ')
    disp('      power_trans_y  -  Y-axis input ')    
    disp('      power_trans_z  -  Z-axis input ')   
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
    disp(' ');
    disp(' *** Relative Displacement Transmissibility Output Files *** ');
    disp(' ');
    disp('   Output File Columns:  ');
    disp('     Freq    X     Y      Z       alpha    beta     theta   ');
    disp('     (Hz)  (in/G) (in/G) (in/G)  (rad/G)  (rad/G)  (rad/G) ');
%
    disp(' ');
    disp('    Output Filenames:  ');
    disp('      rd_trans_x  -  X-axis input ')
    disp('      rd_trans_y  -  Y-axis input ')    
    disp('      rd_trans_z  -  Z-axis input ')
%
    disp(' ');
    disp(' *** Relative Displacement Power Transmissibility Output Files *** ');
    disp(' ');
    disp('   Output File Columns:  ');
    disp('     Freq      X         Y         Z          alpha            beta  theta ');
    disp('     (Hz)  (in^2/G^2) (in^2/G^2) (in^2/G^2)  ((rad^2)^2/G^2)    <-   <-   ');
%
    disp(' ');
    disp('    Relative Displacement Output Filenames: ');    
    disp('      rd_power_trans_x  -  X-axis input ')
    disp('      rd_power_trans_y  -  Y-axis input ')    
    disp('      rd_power_trans_z  -  Z-axis input ')   