disp(' ');
disp(' matrix_deflation_rod.m  ver 1.0  August 31, 2012 ');
disp(' ');
disp(' by Tom Irvine  Email: tom@vibrationdata.com ');
disp(' ');
%
clear u;
%
clear mass;
clear stiff;
%
clear Kct
clear Mct
%
clear Kctr;
clear Mctr;
%
clear CT;
clear CR;
%
clear Kct_temp;
%
disp(' ');
mass=input(' Enter the mass matrix name:  ');
disp(' ');
stiff=input(' Enter the stiffness matrix name:  ');
%
n=max(size(mass));
%
disp(' ');
disp(' Natural Frequencies prior to Deflation ');
%
[fn,omega,ModeShapes,MST]=Generalized_Eigen_semidefinite(stiff,mass,2);
%
disp(' ');
disp(' Eigenvalues ');
disp(' ');
for i=1:n
    out1=sprintf(' %8.4f ',omega(i)^2);
    disp(out1);
end
%
disp(' ');
disp(' Form the translational constraint matrix ');
%
clear ut;
ut=ones(n,1);
%
CT=zeros(n,n-1);
%
for i=1:n-1
    CT(i,i)=1;
end
%   
den=0;
for i=1:n
    den=den+ut(i)*mass(i,n);  
end
%   
for i=1:n-1
%
    num=0;
    disp(' ');
    for j=1:n
        num=num+ut(j)*mass(j,i);
    end    
%
    CT(n,i)=-num/den;
%    
end
%
CT
%
Mct=CT'*mass*CT;
Kct=CT'*stiff*CT;
%
[fn,omega,ModeShapes,MST]=Generalized_Eigen(Kct,Mct,2);
%
disp(' ');
disp(' Eigenvalues ');
disp(' ');
for i=1:n-1
    out1=sprintf(' %8.4f ',omega(i)^2);
    disp(out1);
end
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
ModeShapes
disp(' ');
disp(' Restored Eigenvalues ');
disp(' ');
clear RE;
RE=CT*ModeShapes;
RE