%Modal Analysis of a 16 story building %stiffness (KK) and mass (M) matrices for a 16 story bldg %the units: kips, inches, and second. KK=[683.45 -390.25 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -390.25 976.15 -585.9 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 -585.9 1171.8 -585.9 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 -585.9 1003.7 -417.8 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 -417.8 835.6 -417.8 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 -417.8 835.4 -417.8 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 -417.8 719.3 -301.5 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 -301.5 603 -301.5 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 -301.5 603 -301.5 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 -301.5 499.23 -197.73 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 -197.73 395.46 -197.73 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 -197.73 395.46 -197.73 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 -197.73 300.53 -102.8 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 -102.8 205.6 -102.8 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 -102.8 205.6 -102.8; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -102.8 102.8]; %stiffness matrix md=[.508*[1 1 1] .505*[1 1 1] .504*[1 1 1 1 1 1 1 1 1 1]]; ml=.244*[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]; m1=md+ml; MM=diag(m1); M=diag(m1); % mass matrix [VV,DD]=eig(KK,MM); % solving the eigenvalue problem [temp1,I]=sort(diag(DD)); %sorting the eigenvalues in ascending order om2=diag(temp1); % digonalizing the sorted eigenvalues Phi=zeros(16,16); % a 16x16 zero matrix that will be filled by eigenvectors for j=1:16, Phi(:,j)=VV(:,I(j)); % sorting the Phi (eigenvectors) accordingly end om=sqrt(om2); % natural frequencies diagonal matrix for i=1:16, %mass normalizing the eigenvectors Phi(:,i)=Phi(:,i)/sqrt(Phi(:,i)'*MM*Phi(:,i)); end % om is the diagonal matrix of natural frequencies and % phi is the matrix of eigenvectors; each column of phi % matrix correspond to one of the mode shapes plot(Phi(:,2)); % plot the 2nd mode shape; by changin 2 to any number between % 1 and 16, the corresponding mode shape will be plotted