ode45
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
When using ode45, I know I can specify the integrand as a function of time. For instance, dx/dt = cos(t) - x.
Is there a way to alternatively specify the integrand as a set of data points? For instance replace cos(t) with a set of data points that I load.
When I try doing this I'm getting an error. I think because of the internal time steps ode45 uses is different than the times steps in my data points. Changing the tspan input to match the time steps in my data points doesn't seem to make any difference in the internal time steps ode45 uses. Is there any way around this problem?
Thank you, Kevin
0 comentarios
Respuesta aceptada
Jan
el 6 de Jul. de 2011
5 comentarios
Jan
el 7 de Jul. de 2011
"Best" is relative. This depends on the dimension of the tabulated data and the demands for accuracy. E.g. using a table with 20 values for a full period of COS has a limited accuracy only. If further knowledge about the tabulated data is available, they should be used: e.g. if the values are differentiable, the 'linear' interpolation is better than 'nearest'. If the 2nd derivative is smooth also, 'cubic' will reply more accurate values. If the time points for the table can be choosen freely, using Tschebyschev polynoms for interpolation has the maximal accuracy over the complete interval.
For a sinusoid with 100 time points over a period I'd choose the cubic interpolation. If speed matters, 1000 time points and linear interpolation might be better. If speed really matters, extract the actual used 5 or 8 lines of code from the slow INTERP1 function to create a much faster version.
Más respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!