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

254 vues (au cours des 30 derniers jours)
Kasun Madusanka
Kasun Madusanka le 22 Déc 2021
Commenté : MD SAIFUL le 4 Mai 2023
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 commentaires
Matt J
Matt J le 22 Déc 2021
Please copy/paste the error message.
MD SAIFUL
MD SAIFUL le 4 Mai 2023
error: =: nonconformant arguments (op1 is 1x1, op2 is 1x20)

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 23 Déc 2021
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.

Catégories

En savoir plus sur Logical 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!

Translated by