Hi everyone,
I am trying to run acode from the link:
Yet I get an eror mesage:
Error using lsqcurvefit (line 286)Function value and YDATA sizes are not equal.
What coulg I be doing wrong?
The code is:
Time = [0 1 2 3 4 5 6 7 8 9];Sdata = [3 17 9 4 8 2 1 9 2 4];Sdata = Sdata'; c0 = rand(3,1);[c,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@Fit,c0,Time,Sdata);function S = Fit(c, t, ~)y0 = rand(3,1); [T,Sv] = ode45(@DifEq, t, y0); function dS = DifEq(t, y) ydot = zeros(3,1); c(4) =2; c(5) =1.5; ydot(1) = (c(1)*y(1).^2) + (c(2)*(y(2))) - (c(3)*y(3)); ydot(2) = (c(3)*y(3)) + (c(4)*y(1)); ydot(3) = (c(1)*y(1).^2) - (c(5)*y(2)) + (c(3)*y(3)); dS = ydot; endS = Sv(:,3);end
Best Answer