Filter löschen
Filter löschen

??? Undefined function or method 'times' for input arguments of type 'function_handle'.

7 Ansichten (letzte 30 Tage)
Hi! I'm having trouble with some of my code. I believe that my functions are not being evaluated properly so i'm getting this error message
??? Undefined function or method 'times' for input arguments of type
'function_handle'.
My code is:
Et=@(t)4*t*exp(-2*t/tbar)/tbar^2;
cCt=@(y)4/3.*(cAo-y(3))-2/3.*(cBo-y(4));
concs=@(t,y)[y(3).*Et;
y(4).*Et;
-k1.*y(3).*y(4);
-0.5.*k1.*y(3).*y(4)-1.5.*k2.*y(4).*cCt];
[T,Y] = ode45(concs,[0 tbar*10],[cAo cBo 0 0]);
tbar, cAo cBo, k1, k2 are defined as scalars elsewhere. I think that my problem lies in the cCt function or maybe the Et function...
Thanks for your help.
PY

Akzeptierte Antwort

Seth DeLand
Seth DeLand am 17 Feb. 2011
Patrick,
I believe that when you make calls to the functions inside of concs, you need to include the arguments for those functions. Should look something like:
concs=@(t,y)[y(3).*Et(t);
y(4).*Et(t);
-k1.*y(3).*y(4);
-0.5.*k1.*y(3).*y(4)-1.5.*k2.*y(4).*cCt(y)];

Weitere Antworten (1)

Patrick Young
Patrick Young am 17 Feb. 2011
thanks!

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by