Inner matrix dimensions must agree

1 回表示 (過去 30 日間)
Ben Newton
Ben Newton 2019 年 10 月 28 日
コメント済み: Rena Berman 2019 年 12 月 12 日
%ben newton swansea university 956205
k = 997.584; %stiffness, units = N/m
m = 10.692; %mass, units = kg
xo = 0.026844; %initial displacement, units = m
vo = 0:0.001:5; %initial velocity, units = m/s
t = 0.735; %time, units = s
x = 0.0852; %dispacement, units = m
c = 36.84; %damping coefficient, units = kg/s
wn = sqrt(k/m); %natural frequency, units = rad/s
ccrit = 2*sqrt(k*m); %critical damping coefficient, units = kg/s
zeta = c/ccrit; %damping ratio, no units
wd = wn*sqrt(1 - zeta^2); %damped natural frequency, units = rad/s
A = sqrt((vo+zeta*wn*xo).^2 + (xo*wd)^2/wd^2);
phi = atan((xo*wd)./vo+zeta*wn*xo); %phase angle, units = radians
x@time = A.*exp(-zeta.*wn.*t)*sin((wd.*t)+phi);
%everythings fine up until the last line, gives the error using * inner matrix dimensions must agree
all matrices used are the same shape an size etc and .* has been used
but i still get the error message
please help
  3 件のコメント
Stephen23
Stephen23 2019 年 11 月 8 日
Original question:
%ben newton swansea university 956205
k = 997.584; %stiffness, units = N/m
m = 10.692; %mass, units = kg
xo = 0.026844; %initial displacement, units = m
vo = 0:0.001:5; %initial velocity, units = m/s
t = 0.735; %time, units = s
x = 0.0852; %dispacement, units = m
c = 36.84; %damping coefficient, units = kg/s
wn = sqrt(k/m); %natural frequency, units = rad/s
ccrit = 2*sqrt(k*m); %critical damping coefficient, units = kg/s
zeta = c/ccrit; %damping ratio, no units
wd = wn*sqrt(1 - zeta^2); %damped natural frequency, units = rad/s
A = sqrt((vo+zeta*wn*xo).^2 + (xo*wd)^2/wd^2);
phi = atan((xo*wd)./vo+zeta*wn*xo); %phase angle, units = radians
x@time = A.*exp(-zeta.*wn.*t)*sin((wd.*t)+phi);
%everythings fine up until the last line, gives the error using * inner matrix dimensions must agree
all matrices used are the same shape an size etc and .* has been used
but i still get the error message
please help
Rena Berman
Rena Berman 2019 年 12 月 12 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (1 件)

Katie
Katie 2019 年 10 月 28 日
You're missing a dot in front of the * in front of the sin
x_time = A.*exp(-zeta.*wn.*t).*sin((wd.*t)+phi);

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by