??? Undefined function or method 'times' for input arguments of type 'function_handle'.
10 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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)];
0 Comments
More Answers (1)
See Also
Categories
Find more on Get Started with 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!