Is there a way to calculate jacobians of Simulink models?
Ältere Kommentare anzeigen
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.
1 Kommentar
Thomas Koopman
am 13 Jun. 2024
I am also really interested in this question! I would also expect that Simulink is capable to compute the total model (not just solver) Jacobian in an analytic block-by-block way. If MathWorks support can revisit this question I would be really happy!
Antworten (2)
Kaustubha Govind
am 19 Jul. 2012
1 Stimme
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.
Matthias
am 19 Jul. 2012
0 Stimmen
2 Kommentare
Kaustubha Govind
am 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.
Matthias
am 24 Jul. 2012
Kategorien
Mehr zu General Applications finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!