Info

此问题已关闭。 请重新打开它进行编辑或回答。

Help understanding the syntax of an ODE

1 次查看(过去 30 天)
Alex Kerzner
Alex Kerzner 2017-5-15
关闭: MATLAB Answer Bot 2021-8-20
I'm trying to understand how the following syntax is interpreted in trying to solve an ODE:
I have
[T,ZZ] = ode113(@(t,Z) dZdt(Z,s,zeta), [0 time_end], Z)
where Z is a vector representing points on a curve. The function dZdt.m takes Z as an input and computes dZdt, and requires s and zeta as constants.
My question is, what purpose does @(t,Z) serve? I cannot find a suitable answer in the documentation. To make me even more confused, I see many examples like
[T,Z] = ode113('function_name',...,...)
which makes me wonder why I can't just enter the string of my function name.

回答(1 个)

Star Strider
Star Strider 2017-5-15
‘My question is, what purpose does @(t,Z) serve?’
It creates a function handle that specifies that ‘t’ and ‘Z’ are arguments to your function. This is what the MATLAB ODE solvers require as their function call syntax.
Note that your function doesn’t have to use ‘t’ in its code or its argument list, but ‘t’ must be in the argument list presented to the ODE solvers, or your ODE solver call will throw a ‘Too many input arguments.’ error when the ODE solver attempts to pass ‘t’ to it as an argument.

此问题已关闭。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by