Dimensions of array being concatenated are not consistent

조회 수: 1 (최근 30일)
Panfilo Armas
Panfilo Armas 2022년 11월 6일
편집: DGM 2022년 11월 6일
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

답변 (2개)

VBBV
VBBV 2022년 11월 6일
u= [um1.' uo]; % transpose um1
  댓글 수: 1
VBBV
VBBV 2022년 11월 6일
편집: VBBV 2022년 11월 6일
for i=2:size(Ag)-1
Matlab uses one based indexing for numeric arrays.

댓글을 달려면 로그인하십시오.


Simon Chan
Simon Chan 2022년 11월 6일
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

카테고리

Help CenterFile Exchange에서 Earthquake Engineering에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by