bldg; % you need to have bldg.m in the same directory as this m-file % bldg.m evaluates the natural frequencies and mode shapes of the % 16 story building p=size(M); % M is the mass matrix from bldg.m e=ones(p(1),1); % vector with the same size as M and entries of 1 xi=0.02; % A damping ratio of xi is assumed for all the modes % by setting xi=0, the undamped system will be modeled A=[zeros(p(1)) diag(ones(1,p(1)));-om2 -2*xi*om];% with damping B=[zeros(p(1)); Phi']*M*e; %earthquake input matrix % note that earthquake signals are normally collected by accelerometers % and in simulation acceleration at the base of the building is viewed as % the input to the system. Acceleration at the base can be changed by forces % on each mass with the magnitude of m_of_each_floor*acceleration_of_the_base % to simulate the response of the building to a single force acting on one of the % floors, say 10th floor, change B to the following (comment the above B) and % uncomment the B, below %B=[zeros(p(1),1); (Phi(10,:))']; C=[Phi(16,:) zeros(1,16)]; % displacement is the output D=zeros(1); %control input D matrix w=logspace(0,2,100); bode(A,B,C,D,1,w); % bode plot for the 16th floor title('bode plot for the 16th floor')