In MATLAB: How do I pass a parameter to a function?,
it is said that if i want to pass the parameter u
, i need to use anonymous function:
u = 1.2;
[t y] = ode45(@(t, y) ypdiff(t, y, u), [to tf], yo);
Originally, without passing parameter u
, the ode line reads:
[t y] = ode45(@ypdiff, [to tf], yo);
, where @ypdiff
just creates a function handle.
Why if we want to pass u
only, we also need to include t
and y
in the creation of anonymous function @(t, y) ypdiff(t, y, u)
, but not something like @ypdiff(u)
?