Is there a way to calculate jacobians of Simulink models?
6 views (last 30 days)
Show older comments
Hello,
I have a Simulink model of a general ODE of the form
x\dot = f(x,u).
To be able to do sensitivity analysis I would need the gradients of the dynamics with respect to the states df/dx and the inputs df/du along the whole simulated trajectory. As implementing the gradients of the model by hand can be a very daunting task for complex models, I am looking for a method to generate these gradients automatically. I think Simulink is able to calculate the jacobians of the dynamics analytically as they are used in the implicit integrators. Nevertheless, I did not find a way to use these gradients anywhere else. Finite differences or any other numerical methods are no alternative because runtimes are crucial to the application.
For me the ideal solution would be to "parse" the Simulink model once, to generate the analytical gradients of the model, that can afterwards be used to calculate the numerical jacobian in every timestep.
Thank you very much for your help.
0 Comments
Answers (2)
Kaustubha Govind
on 19 Jul 2012
I'm not entirely sure if this is what you're looking for, but it is possible to get the Solver Jacobian Pattern for a Simulink model. Please see Exploring the Solver Jacobian Structure of a Model for more information.
0 Comments
Matthias
on 19 Jul 2012
2 Comments
Kaustubha Govind
on 20 Jul 2012
Matthias: You can convert a sparse matrix to a full matrix using the FULL function. For the example, you simply need to use full(J.Jpattern) to get the full Jacobian matrix.
See Also
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!