Effacer les filtres
Effacer les filtres

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

7 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Seth DeLand
Seth DeLand le 17 Fév 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)];

Plus de réponses (1)

Patrick Young
Patrick Young le 17 Fév 2011
thanks!

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by