简体   繁体   中英

ode solver Matlab

I am trying to understand the syntax of the ode45 and I don't understand why sometimes it's ode45(odefun, tspan, y0) and other times ode45(@odefun, tspan, y0). I would like to understand the meaning of the @ in front of the function odefun. Especially,the following syntax is not clear to me : (it should solve the equation y'=2*t)


tspan = [0 5];
y0 = 0;
[t,y] = ode45(@(t,y) 2*t, tspan, y0); 

Does @(t,y) means diff(t,y) ? why are there no sign equal between @(t,y) and 2*t, all this remains very mysterious to me ... If someone could light me, it would be great. I thank you very much, With best regards,

@odefun is an older or alternative method to refer to the function odefun .

@(t,y) 2*t

is an anonymous function or lambda expression logically equivalent to

function dy = odefun(t,y)
    dy = 2*t
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM