Is there a way to calculate jacobians of Simulink models?
Mostrar comentarios más antiguos
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 comentario
Thomas Koopman
el 13 de Jun. de 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!
Respuestas (2)
Kaustubha Govind
el 19 de Jul. de 2012
1 voto
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
el 19 de Jul. de 2012
0 votos
2 comentarios
Kaustubha Govind
el 20 de Jul. de 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
el 24 de Jul. de 2012
Categorías
Más información sobre General Applications en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!