Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Seth DeLand
Seth DeLand il 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)];

Più risposte (1)

Patrick Young
Patrick Young il 17 Feb 2011
thanks!

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by