%% Convert Second-Order Differential Equation to First-Order System
% Define a second-order differential equation:
% \frac{d^2 y}{{\textrm{dt}}^2 }+y^2 t=3t\ldotp
% Convert the second-order differential equation to a system of first-order differential equations.

syms y(t)
eqn = diff(y,2) + y^2*t == 3*t;
V = odeToVectorField(eqn)

% The elements of V represent the system of first-order differential equations, where V[i] = {Y_i}' and Y_1=y. Here, the output V represents these equations:
% \frac{dY_1 }{\textrm{dt}}=Y_2
% \frac{{\textrm{dY}}_2 }{\textrm{dt}}=3t-tY_1^2 \ldotp
% For details on the relation between the input and output, see Algorithms.
%
% Copyright 2012-2019 The MathWorks, Inc.
%