Filter löschen
Filter löschen

How can I make matrix dimensions to agree?

1 Ansicht (letzte 30 Tage)
Dursman Mchabe
Dursman Mchabe am 9 Okt. 2018
Bearbeitet: KALYAN ACHARJYA am 9 Okt. 2018
Hi all, I get an error message:
Matrix dimensions must agree.
Error in lsqcurvefit/objective (line 279)
F = F - YDATA;
Error in snls (line 333)
newfvec = feval(funfcn{3},xcurr,varargin{:});
Error in lsqncommon (line 167)
snls(funfcn,xC,lb,ub,flags.verbosity,options,defaultopt,initVals.F,initVals.J,caller, ...
Error in lsqcurvefit (line 271)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,allDefaultOpts,caller,...
Error in CurveFitting (line 135)
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);
when I run the attached code. What could be the cause of the disagreement?
Kind Regards Dursman

Akzeptierte Antwort

KALYAN ACHARJYA
KALYAN ACHARJYA am 9 Okt. 2018
Bearbeitet: KALYAN ACHARJYA am 9 Okt. 2018
That means F =F-YDATA must be in the same dimension.
Please ensure that F and TDATA must be same before doing subtraction operation.
I have noticed in your code dcdt(2), dcdt(3),...what do these mean, are those scalar or vector variables?
Why you mixed up the function descriptions with other body code?
  2 Kommentare
Dursman Mchabe
Dursman Mchabe am 9 Okt. 2018
Thanks a lot for the answer.
dC = dcdt
And dcdt is a set of 7 differential equations dcdt(1) ... dcdt(7).
They are vectors.
KALYAN ACHARJYA
KALYAN ACHARJYA am 9 Okt. 2018
Bearbeitet: KALYAN ACHARJYA am 9 Okt. 2018
Welcome, @Dursman If all dcdt(1) ... dcdt(7) are calculated from the same expression, you can use the dcdt(i) indexing the way to find it.
Happy to Help

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by