How to solve this error: =: nonconformant arguments (op1 is 1x1, op2 is 100x1)?

238 ビュー (過去 30 日間)
Kasun Madusanka
Kasun Madusanka 2021 年 12 月 22 日
コメント済み: MD SAIFUL 2023 年 5 月 4 日
This is the code I am using.
m1=3936/10;
m2=3936/20;
c1=3936/10;
c2=3936/20;
k1=3936;
k2=3936/2;
T = linspace(0, 10)'; % Time
f = 0.1; % Frequency
Am = 10; % Phase
F = Am*sin(2*pi*f*T); % Sin wave input
function dydt = damper_sys(t,y,m1,m2,c1,c2,k1,k2,F)
dydt=zeros(4,1);
dydt(1)=y(2);
dydt(2)=-(k2/m2)-(c2/m2)+(k2/m2)+(c2/m2);
dydt(3)=y(4);
dydt(4)=(k2/m1)+(c2/m1)-(k1+k2)/m1-(c1+c2)/m1 + F/m1;
end
tspan=[0 10];
init=[0;0;0;0];
options=odeset('Maxstep',0.1);
% [t,y]=ode45(@(t,y) damper_sys(t,y,m1,m2,c1,c2,k1,k2,F),tspan,init,options);
The given error is,
"error: =: nonconformant arguments (op1 is 1x1, op2 is 100x1) error: called from damper_sys at line 6 column 12 @<anonymous> at line 1 column 20 starting_stepsize at line 53 column 5 ode45 at line 196 column 25"
  2 件のコメント
Matt J
Matt J 2021 年 12 月 22 日
Please copy/paste the error message.
MD SAIFUL
MD SAIFUL 2023 年 5 月 4 日
error: =: nonconformant arguments (op1 is 1x1, op2 is 1x20)

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

回答 (1 件)

Jan
Jan 2021 年 12 月 23 日
T = linspace(0, 10)'; % Time
f = 0.1; % Frequency
Am = 10; % Phase
F = Am*sin(2*pi*f*T); % Sin wave input
Now F is a [100, 1] vector.
In the function t be integrated:
dydt(4) = (k2/m1) + (c2/m1) - (k1+k2) / m1 - (c1 + c2) / m1 + F / m1;
% ^ scalar ^ [100, 1]
This must fail, because the right side is a vector and the left side is a scalar.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by