Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

ode_rk45 (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

Owning Class: ode

Requires: MathScript RT Module

Syntax

[t, y] = ode_rk45(fun, times, y0)

[t, y] = ode_rk45(fun, times, y0, options)

Legacy Name: ode45

Description

Uses the Runge-Kutta 45 ODE solver to determine the y-values in an ODE system. ode_rk45(fun, times, y0) uses default parameters or parameters set by odepset(name1, value1, ..., nameN, valueN) for the ODE solver. ode_rk45(fun, times, y0, options) uses parameters specified in options for the ODE solver.

Details

Examples

Inputs

Name Description
fun Specifies the name of the function, defined and saved in a .m file, that describes the ODE system. The function must have the following form: function dy = fun(times, y). fun is a string.
times Specifies either the starting time and ending time for the time span, such as [0, 20], or the time points, such as 1:20. times must be strictly monotonic and is a real, double-precision vector.
y0 Specifies the y-value at the starting time. y0 is a real, double-precision vector.
options Specifies the parameters for the ODE solver. options is a structure containing the parameters for the ODE solver.

Outputs

Name Description
t Returns the time values at which LabVIEW evaluates the y-values. t is a real, double-precision vector.
y Returns the y-values that LabVIEW approximates. y is a real, double-precision matrix.

Details

If you specify the starting and ending time for the time span in times, LabVIEW automatically adjusts the time step size throughout the calculation to ensure that the error per step remains at a given relative and absolute tolerance. If you specify the time points in times, LabVIEW also automatically adjusts the time step size to ensure a more accurate calculation. However, LabVIEW returns only the y-values at the time points you specify, and t equals times.

This function is supported in the LabVIEW Run-Time Engine and on RT targets if the .m file you defined and saved for the fun parameter is a string constant.

The following table lists the support characteristics of this function.

Supported in the LabVIEW Run-Time Engine Yes (if you request output)
Supported on RT targets Yes (if you request output)
Suitable for bounded execution times on RT Not characterized

Examples

% The lorenz function is defined by:
% function DY = lorenz(times, y)
% DY = zeros(3, 1);
% DY(1) = 10*(y(2)-y(1));
% DY(2) = 28*y(1)-y(2)-y(1)*y(3);
% DY(3) = y(1)*y(2)-8/3*y(3);
[T, Y] = ode_rk45('lorenz', [0, 5], [1; 1; 1])

odepset('AbsTol', 1E-3, 'MinStep', 1E-8, 'MaxStep', 1)
[T2, Y2] = ode_rk45('lorenz', [0, 5], [1; 1; 1])

options = odepset
[T3, Y3] = ode_rk45('lorenz', [0, 5], [1; 1; 1], options)


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit