
  clear;
close all;
%----------------------------------------------------
%Problem 9.2 from book
%First will define the connectivity between the local and global
%coordinates
%
id = [0  2  5;...
      0  3  6;...
      1  4  7;...
      2  5  0;...
      3  6  0;...
      4  7  8];
%Form element stifness matrices - 1st order
[k1] = frame(0,0,0,5000,200,6.36e8,2.5e4);
[k2] = frame(0,5000,4000,5000,200,8.61e8,1.76e4);
[k3] = frame(4000,5000,4000,0,200,6.36e8,2.5e4);
%
%Assemble global stifness matrix - 1st order
KO = zeros(8,8);
[KO] = addk(KO,k1,id,1);
[KO] = addk(KO,k2,id,2);
[KO] = addk(KO,k3,id,3)
%
% Form element geometric stiffness matrices - linearized
[k1g] = frameg(0,0,0,5000,200,6.36e8,2.5e4,1.0);
[k2g] = frameg(0,5000,4000,5000,200,8.61e8,1.76e4,0.0);
[k3g] = frameg(4000,5000,4000,0,200,6.36e8,2.5e4,1.0);
%
%Assemble global geometric stifness matrix -  linearized
KG = zeros(8,8);
[KG] = addk(KG,k1g,id,1);
[KG] = addk(KG,k2g,id,2);
[KG] = addk(KG,k3g,id,3)
%
%Solving the eigenvalue problem
[V,D]=eig(KO,KG);
buckle=V
Pcr=D