- Write an S-Function in MATLAB that calculates the Jacobian. This usually involves numerical differentiation, where you perturb each state slightly and observe the change in outputs. Integrate this function with Simulink using the “s-function” block, by specifying the name of the MATLAB file corresponding to the S-Function. You can refer to the documentation of the “s-function” for more information: https://www.mathworks.com/help/releases/R2021a/simulink/s-function-basics-matlab.html
- Use the “jacobian” function of the “Symbolic Math toolbox” by manually coding the equations. To use this toolbox, you can create a separate MATLAB script and generate the Jacobian matrix in using the “jacobian” function. Then, this script can be added to the Simulink model by using the “MATLAB function” block. You can refer to the documentation of the function for more information: https://www.mathworks.com/help/releases/R2021a/symbolic/sym.jacobian.html
How to use the Jacobian Matrix elements during a Simulink Simulation
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to do some computations that use the elements of the Jacobian Matrix. Is it possible to use the Jacobian that Simulink is generating (or the one related to the previous iteration) at each time step inside a Matlab Function, for example?
For now I'm working with a simple RLC circuit as initial test (see the attached model). Variables are defined in a callback function, and the same equation is solved using Simulink blocks, Specialized Power Systems and Simscape Electrical.
Thank you in advance for your time and consideration!
0 commentaires
Réponses (1)
Aabha
le 12 Fév 2025
It seems that the functionality of accessing or finding the Jacobian matrix of a Simulink model is not available. However, there are a few possible workarounds that you could try and see if any of those meet your requirements:
It is also possible to get the Solver Jacobian Pattern for a Simulink model. The Solver Profiler supports Jacobian logging and analysis, but only for models that use implicit solvers. You can refer to this link for more details: https://www.mathworks.com/help/releases/R2021a/simulink/slref/exploring-the-solver-jacobian-structure-of-a-model.html
I hope some of these workarounds are helpful to you.
0 commentaires
Voir également
Catégories
En savoir plus sur General Applications dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!