Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Help understanding the syntax of an ODE
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Star Strider
le 15 Mai 2017
‘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.
0 commentaires
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!