Dimensions of array being concatenated are not consistent
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I'm trying to use the Central Difference method to do a strucutral analysis of a structure subjected to an earthquake. I should be getting the displacements for every time period with the acceleration but I keep getting the error " Dimensions of array being concatenated are not consistent". Can anyone help and see what I might be inputting incorrectly? I have my code below
clear all
clc
EC=xlsread('KobeAT2H'); % Define Earthquake Motion
t=EC(:,1); % Time Vector from El Centro GM Data
Ag=EC(:,2); % Acceleration vector from El Centro Data in/^sec^2
plot(t,Ag)
xlabel('Time (sec)')
ylabel('Acceleration (g) for El centro Earthquake')
% Parameters of Structure
dt=0.01;
g=386.4; %Acceleration of Gravity in in/s^2
b=0.0775; % Base length of Columns (inch)
h=12; % Height of Columns in Each floor(inch)
E=29000; % Elastic Modulus of Structure (ksi) Steel
I=b*h^3/12; % Second-Moment of Inertia of Columns (in^4)
ks=24*(E*I/h^3); %Stiffness Kip/in
M=13.8; % Total Mass of Steel Structure
Wn=sqrt(ks/M); % Natural Frequency
c=2*M*0.02*Wn; %Damping
% Central difference Method
p=-M*Ag; % Initial Force at time 0
uo=0; % Initial Displacement
u1=0; % Initial Velocity
udd=(p-c*u1-ks*uo)/M;
um1=uo-(dt)*u1+(dt)^2/2*udd;
khat=M/(dt^2)+(c/2*dt);
a=(M/(dt)^2)-c/(2*dt);
b=ks-(2*M/dt^2);
% initialize vectors
phat = [];
u= [um1 uo];
for i=1:size(Ag)
phat(i-1)=p(i+1)-a*um1(i-1)-b*u1;
u(i+1) = phat(i+1)/khat;
end
0 commentaires
Réponses (2)
Simon Chan
le 6 Nov 2022
Variable um1 is a column vector which have the same size as variable t or Ag. However, variable uo is a scalar which is equals to 0 in your case. Therefore, you get the mentioned error in
u= [um1 uo];
Furthermore, the indexing in the for-loop is also not correct since it is not possible to get phat(0) when i=1.
for i=1:size(Ag)
phat(i-1)=p(i+1)-a*um1(i-1)-b*u1;
u(i+1) = phat(i+1)/khat;
end
0 commentaires
Voir également
Catégories
En savoir plus sur Seismology dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!