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

19 views (last 30 days)
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

Accepted Answer

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

More Answers (1)

Patrick Young
Patrick Young on 17 Feb 2011
thanks!

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!