disp(' ');
disp(' mdof_base_accel_frf_fea.m,  ver 1.5, October 8, 2012 ');
disp(' ');
disp(' by Tom Irvine ');
disp(' Email: tom@vibrationdata.com ');
disp(' ');
disp(' This script calculates the natural frequencies of a    ');
disp(' multi-degree-of-freedom system. It also calculates the ');
disp(' frequency response functions for base excitation.      ');
disp(' ');
disp(' A base mass is required, but the mass value is arbitrary. ');
disp(' ');
%
close all;
%
clear stiff;
clear mass;
%
clear Mdd;  % driven
clear Mdf;
clear Mfd;
clear Mff;  % free
%
clear Mdw;
clear Mwd;
clear Mww;
%
clear MP;
clear MT;
%
clear Kdd;  
clear Kdf;
clear Kfd;
clear Kff;
%
clear invKff;
%
clear Kww;
%
clear KP;
clear KT;
%
clear n;
clear na;
clear nv;
clear nd;
%
clear m;
clear k;
%
clear TT;
clear T1;
clear T2;
%
clear I;
clear Idd;
clear Iff;
%
clear damp;
clear ea;
clear f;
clear ngw;
clear C;
clear freq;
clear nodex;
clear dof;
clear nem;
%
clear omega;
clear omegan;
%
clear length;
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
fig_num=1;
%
%
disp(' ');
disp(' Select units:  1=English 2=metric ');
iu=input(' ');
%
if(iu==1)
    disp(' Select mass unit ');
    disp('  1=lbm ');
    disp('  2=lbf sec^2/in  ');
    imu=input(' ');
%
    if(imu==1)
        disp(' Enter mass matrix (lbm)');
    else
        disp(' Enter mass matrix (lbf sec^2/in)');    
    end
    mass=input(' ');
%
    if(imu==1)
        mass=mass/386;
    end
%
    disp(' Enter stiffness matrix (lbf/in)');
    stiff=input(' ');
else
    disp(' Enter mass matrix (kg)');   
    mass=input(' ');
%
    disp(' Enter stiffness matrix (N/m)');
    stiff=input(' ');   
end
%
sz=size(mass);
dof=(sz(1));
num=dof;
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
out1=sprintf('\n number of dofs =%d \n',num);
disp(out1);
%
%
disp(' ');
disp(' Select drive input method ');
disp('  1=manual entry ');
disp('  2=vector ');
idrvm=input(' ');
%
disp(' ');
if(idrvm==1)
%    
   disp(' Enter the number of drive dofs ');
   idn=input(' ');
%
   ea=zeros(idn,1);
%
   for i=1:idn
       out1=sprintf(' Enter drive dof number %d  ',i);
       disp(out1);
       ea(i)=input('  ');
   end
%
else
   disp(' Enter the drive dof vector  ');
   ea = input('  ');
end
%
nem=length(ea);
%
nff=num-nem;
%
[nff,ngw,Mwd,Mww,fn,omegan,ModeShapes,MST,PF,T1,T2]=...
 partition_matrices_accel(num,nem,ea,mass,stiff);
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
disp(' ');
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 ');
   damp = input(' Enter the vector:  ');
end
%
%
[acc_frf,fstart,fend,freq]=...
 partition_matrices_accel_frf(num,nff,nem,ngw,Mwd,Mww,fn,damp,omegan,...
                                          ModeShapes,MST,PF,T1,T2);
%
[trans_acc_frf,trans_vel_frf,trans_disp_frf,trans_rel_disp_frf]=...
    mdof_base_fea_post(acc_frf,freq,fstart,fend,fig_num,num,iu);
%
%
disp(' ');
disp(' Apply half-sine base input?  1=yes  2=no ');
isb=input(' ');
if(isb==1)
%
   [t,acc,rel_disp,abase]=...
              mdof_half_sine_core(fn,damp,PF,ModeShapes,T1,T2,ngw);   
%
   [acc_half_sine,rel_disp_half_sine,fig_num]=...
              mdof_base_th_plot(t,acc,rel_disp,abase,fig_num);   
end    
%
disp(' ');
disp(' Apply arbitrary time history base input?  1=yes  2=no ');
iar=input(' ');
if(iar==1)
%  
   [t,acc,rel_vel,rel_disp,abase]=...
              mdof_arbit_base_core(fn,damp,PF,ModeShapes,T1,T2,ngw);
%
   [acc_arb,rel_disp_arb,fig_num]=...
              mdof_base_th_plot(t,acc,rel_disp,abase,fig_num); 
end
%
%
disp(' ');
disp(' Output arrays: ');
disp(' ');
disp('   trans_acc_frf');
disp('   trans_vel_frf');
disp('   trans_disp_frf');
disp('   trans_rel_disp_frf');
%
if(isb==1)
    disp('   acc_half_sine');
    disp('   rel_disp_half_sine');       
end
%
if(iar==1)
    disp('   acc_arb');
    disp('   rel_disp_arb');       
end
%
disp(' ');
disp(' Save arrays to binary?  1=yes 2=no ');
isb=input(' ');
if(isb==1)
    disp(' ');
    disp(' Enter filename with *.mat extension. ');
    bin_filename = input(' ','s');
    save(bin_filename,'trans_acc_frf','trans_vel_frf','trans_disp_frf','trans_rel_disp_frf','-mat');
end
%