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

311 views (last 30 days)
Kasun Madusanka on 22 Dec 2021
Commented: Kasun Madusanka on 26 Dec 2021
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"
Matt J on 22 Dec 2021

Jan on 23 Dec 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.
Kasun Madusanka on 26 Dec 2021
Thank you very much for your help.