symDynJac
Return the symbolically generated partial derivatives (required for sensitivity) from an ODE function handle
Syntax
[dfdz,dfdp] = symDynJac(ode)
[dfdz,dfdp] = symDynJac(ode,nstates)
[dfdz,dfdp] = symDynJac(ode,nstates,nparam)
[dfdz,dfdp,sym_dfdz,sym_dfdp] = symDynJac(ode)
Description
[dfdz,dfdp] = symDynJac(ode) converts the function handle ode into a symbolic expression, calculates the partial derivatives using the Symbolic Toolbox command Jacobian, then converts each derivative expression back to a function handle as dfdz (derivative with respect to states, z) and dfdp (derivative with respect to parameters, p).
[dfdz,dfdp] = symDynJac(ode,nstates) ensures the correct number (nstates) of states is used in the resulting Jacobian. This is useful if your function does not include all indices of z.
[dfdz,dfdp] = symDynJac(ode,nstates,nparam) ensures the correct number (nparam) of parameters is used in the resulting Jacobian. This is useful if your function does not include all indices of p.
[dfdz,dfdp,sym_dfdz,sym_dfdp] = symDynJac(ode) also returns the intermediate symbolic expressions of the partial derivatives.
Important Notes
This function uses the Matlab Symbolic Toolbox® thus you must have this installed to use this function. This is also a very basic routine thus you may wish to confirm the solution via one of the other differentiation routines provided.
The form of your function handle must be as follows:
ode = @(t,z,p) z(1) + p(1)*z(2); where the function is only a function of t,z, and p, and all variables are indexed into the expression (no vectorized calls).
Example
>> ode = @(t,z,p) [z(2);
p(1)*(1-z(1)^2)*z(2) - z(1)];
>> [dfdz,dfdp] = symDynJac(ode)
dfdz =
@(t,z,p)[[0,1];[-2*p(1)*z(1)*z(2)-1,-p(1)*(z(1)^2-1)]]
dfdp =
@(t,z,p)[[0];[-z(2)*(z(1)^2-1)]]
Copyright © 2011-2013 Jonathan Currie (I2C2)