function [phi globalK globalA] = findphi( weight,nmode )
constants
K=EI/l^3*[12, 6*l, 0, -12, 6*l, 0; 6*l, 4*l^2, 0, -6*l, 2*l^2, 0; 0, 0, GJ*(l^2)/EI, 0, 0, -GJ*(l^2)/EI; -12, -6*l, 0, 12, -6*l, 0;6*l, 2*l^2, 0, -6*l, 4*l^2, 0; 0, 0, -GJ*(l^2)/EI, 0, 0, GJ*(l^2)/EI];
A=m/2*[1,l/2, -d, 0, 0, 0;l/2, Iz/m+(l/2)^2, -d*l/2, 0, 0, 0; -d, -d*l/2, Ix/m+d^2, 0, 0, 0; 0, 0, 0, 1, -l/2, -d; 0, 0, 0, -l/2, Iz/m+(l/2)^2, d*l/2;0, 0, 0, -d, d*l/2, Ix/m+d^2];

globalK=zeros(6+3*(N-1),6+3*(N-1));

for w=0:3:3*N-1
    for i=1:1:6
        for j=1:1:6
            globalK(i+w,j+w)=globalK(i+w,j+w)+K(i,j);
        end
    end
end

globalK(:,1:3) = [];
globalK(1:3,:)=[]; 

globalA=zeros(6+3*(N-1),6+3*(N-1));

for w=0:3:3*N-1
    for i=1:1:6
        for j=1:1:6
            globalA(i+w,j+w)=globalA(i+w,j+w)+A(i,j);
        end
    end
end
globalA(:,1:3) = [];
globalA(1:3,:)=[]; 

% [phi gamda]=eigs(globalA^-1*globalK,nmode,'sm');
% 
%central pod
mcp=0.5*250*0.4536; %Kg
rcy=3*0.3048;
rcx=0.5*l;
IxExtra=mcp*rcy^2;
IzExtra=mcp*(rcx^2+rcy^2);
dExtra=0;
mExtra=mcp;
extraA=mExtra/2*[1,l/2, -dExtra, 0, 0, 0;l/2, IzExtra/mExtra+(l/2)^2, -dExtra*l/2, 0, 0, 0; -dExtra, -dExtra*l/2, IxExtra/mExtra+dExtra^2, 0, 0, 0; 0, 0, 0, 1, -l/2, -dExtra; 0, 0, 0, -l/2, IzExtra/mExtra+(l/2)^2, dExtra*l/2;0, 0, 0, -dExtra, dExtra*l/2, IxExtra/mExtra+dExtra^2];
globalA(1:6,1:6)=globalA(1:6,1:6)+extraA;

%side pod
msp=50*0.4536; %Kg
IxExtra=msp*rcy^2;
IzExtra=msp*(rcx^2+rcy^2);
dExtra=0;
mExtra=msp;
extraA=mExtra/2*[1,l/2, -dExtra, 0, 0, 0;l/2, IzExtra/mExtra+(l/2)^2, -dExtra*l/2, 0, 0, 0; -dExtra, -dExtra*l/2, IxExtra/mExtra+dExtra^2, 0, 0, 0; 0, 0, 0, 1, -l/2, -dExtra; 0, 0, 0, -l/2, IzExtra/mExtra+(l/2)^2, dExtra*l/2;0, 0, 0, -dExtra, dExtra*l/2, IxExtra/mExtra+dExtra^2];
globalA(2*N-5:2*N,2*N-5:2*N)=globalA(2*N-5:2*N,2*N-5:2*N)+extraA;

[phi gamda]=eigs(globalA^-1*globalK,nmode,'sm');
            
        
            
    

end


