Reputation: 1
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,
Upvotes: 0
Views: 113
Reputation: 25972
@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
Upvotes: 1