Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Help understanding the syntax of an ODE
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Star Strider
el 15 de Mayo de 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 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!