Text-only
Table of Contents (
frame
/
no frame
)
(23) Matlab Anonymous Function Example
Anonymous Function Example
@
operator creates a function handle
try:
f=@(x)(sin(x)+cos(x));
f(2)
function ode_ex1
xstart =0;
xfinal =7;
xrange=xstart:.2: xfinal;
y0=1;
dydx=@(x,y) x+y;
[x,y]=ode45(dydx,xrange,[y0]);
ya= 2*exp(xrange)-xrange-1;
plot(x,y,'r',x,ya,'+');
try:
>> ode_ex1
Anon_func_example.src last modified Oct 17, 2007
Introduction
Table of Contents
(
frame
/
no frame
)
Printable
(single file)
© Dartmouth College