%% Return Substitutions Made When Reducing Order of Differential Equations
% When reducing the order of differential equations, return the substitutions that odeToVectorField makes by specifying a second output argument.

syms f(t) g(t)
eqn1 = diff(g) == g-f;
eqn2 = diff(f,2) == g+f;
eqns = [eqn1 eqn2];
[V,S] = odeToVectorField(eqns)

% The elements of V represent the system of first-order differential equations, where V[i] = {Y_i}'. The output S shows the substitutions being made, S[1] = Y_1 = f, S[2] = Y_2 = diff(f), and S[3] = Y_3 = g.
%
% Copyright 2012-2019 The MathWorks, Inc.