%
%  mdof_base_fea_post.m  ver 1.1  September 25, 2012
%
function[trans_acc_frf,trans_vel_frf,trans_disp_frf,trans_rel_disp_frf]=...
    mdof_base_fea_post(acc_frf,freq,fstart,fend,fig_num,nnn,iu)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
freq=freq';
omega=2*pi*freq;
%%
%
nfreq=max(size(freq));
%
trans_acc_frf=zeros(nfreq,nnn);
trans_vel_frf=zeros(nfreq,nnn);
trans_disp_frf=zeros(nfreq,nnn);
%
for i=1:nnn
%    
     trans_acc_frf(:,i)=acc_frf(:,i);
%     
     for j=1:nfreq
         trans_vel_frf(j,i)=acc_frf(j,i)/omega(j);    
        trans_disp_frf(j,i)=acc_frf(j,i)/omega(j)^2;
%
        trans_rel_disp_frf(j,i)=trans_disp_frf(j,i) - 1/omega(j)^2;
%
     end
%     
end
%
if(iu==1)
             trans_vel_frf=trans_vel_frf*386;
        trans_disp_frf=trans_disp_frf*386;
    trans_rel_disp_frf=trans_rel_disp_frf*386;
end
%
         trans_acc_frf=[freq abs( trans_acc_frf  )];
         trans_vel_frf=[freq abs( trans_vel_frf  )]; 
        trans_disp_frf=[freq abs( trans_disp_frf )]; 
    trans_rel_disp_frf=[freq abs( trans_rel_disp_frf )];     
%
%%
i=1;
while(i==1)
%
    disp(' ');
    sn=input(' Enter response dof for plotting ');
%
    figure(fig_num);
    fig_num=fig_num+1;
    plot(freq,trans_acc_frf(:,sn+1));
    grid on;
    xlabel('Frequency (Hz)');
    ylabel('Response Accel/Base Accel (G/G) ');
%
    out1=sprintf(' Accel FRF  dof %d ',sn);
    title(out1);
%
    set(gca,'MinorGridLineStyle',':','GridLineStyle',':','XScale',...
               'log','YScale','log','XminorTick','on','YminorTick','on');           
%
    [fmin,fmax,ymin,ymax]=find_plot_limits(freq,trans_acc_frf(:,sn+1));
    axis([fstart,fend,ymin,(ymax*1.01)])
%
    figure(fig_num);
    fig_num=fig_num+1;
    plot(freq,trans_rel_disp_frf(:,sn+1));
    grid on;
    xlabel('Frequency (Hz)');
    if(iu==1)
        ylabel('Response Relative Displacement/Base Accel (in/G) ');
    else
        ylabel('Response Relative Displacement/Base Accel (m/G) ');        
    end
%
    out1=sprintf(' Rel Disp FRF  dof %d ',sn);
    title(out1);
%
    set(gca,'MinorGridLineStyle',':','GridLineStyle',':','XScale',...
               'log','YScale','log','XminorTick','on','YminorTick','on');           
%
    [fmin,fmax,ymin,ymax]=find_plot_limits(freq,trans_rel_disp_frf(:,sn+1));
    axis([fstart,fend,ymin,(ymax*1.01)]);    
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
    af=[freq trans_acc_frf(:,sn+1) ];
%
    [xmax,ymax]=find_max(af);
    disp(' ');
    out1=sprintf('    Accel FRF:  max = %8.3g G/G at %8.4g Hz  ',xmax,ymax);
    disp(out1);    
%    
    rf=[freq trans_rel_disp_frf(:,sn+1) ];
%
    [xmax,ymax]=find_max(rf);
    if(iu==1)
        out1=sprintf(' Rel Disp FRF:  max = %8.3g in/G at %8.4g Hz  ',xmax,ymax);
    else
        out1=sprintf(' Rel Disp FRF:  max = %8.3g m/G at %8.4g Hz  ',xmax,ymax);       
    end
    disp(out1);    
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
    disp(' ');
    disp(' Plot another dof response?  1=yes 2=no ');
    i=input(' ');
%
end
%