Unable to perform assignment because the left and right sides have a different number of elements.

1 view (last 30 days)
Hi guys,
I need some help with the following code:
function xd=f1(t, x, YH, YA, fp, iXB, miuH, bH, KS, KOH, KNO, miuA, bA, KOA, KNH, niug, ka, kh, KX, niuh)
...
Xset =0.2;
er = x(3)-Xset;
Ds= Kp*er + Ki*x(14);
...
xd(3)=-(1/YH)*(p1+p2)+p7+Ds*SSin-Ds*x(3);
...
xd(14)=er;
Script:
global D SSin XSin XPin XNDin SNDin SNHin SNOin SOin SALKin alpha W Ssat Kp Ki
...
Tu = Y*2.6;
Ku = W-SSin;
Kp = 0.45*Ku;
Ki = 0.54*Ku/Tu;
...
x0=[10 10 2*30 2*70 0 1 1 10 2 2 10 0 0 0];
...
I have this error:
Error in f1 (line 37)
xd(3)=-(1/YH)*(p1+p2)+p7+Ds*SSin-Ds*x(3); % SS
Error in
script>@(t,x)f1(t,x,YH,YA,fp,iXB,miuH,bH,KS,KOH,KNO,miuA,bA,KOA,KNH,niug,ka,kh,KX,niuh)
(line 57)
[t,x]=ode45(@(t,x)f1(t,x, YH, YA, fp, iXB, miuH, bH, KS, KOH, KNO, miuA,
bA, KOA, KNH, niug, ka, kh, KX, niuh), [t0 tf], x0);
Can you help me, please?
Thanks!
  3 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Jun 2021
One of your global variables is not initialized.
Avoid using global variables.
https://www.mathworks.com/help/matlab/math/parameterizing-functions.html

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!