My 6x6 symbolic Jacobian matrix is massive, and matlabFunction( ) is having trouble writing the corresponding numerical function file.
조회 수: 9 (최근 30일)
이전 댓글 표시
Hi there!
I currently have a 6x6 symoblic Jacobian using the Symbolic Math Toolbox. It is massive, when I take a peek at it using the Command Window. I then used matlabFunction( ) to convert this symbolic Jacobian to a numerical function. If I use matlabFunction's default optimize = true, the numerical function file is about 8,000 lines of code, and I get a message there that says the code is too complex to analyze, and that I should reduce the number of operations in my code. On the other hand, if I use matlabFunction's optimize = false option, the numerical function file is 59,506 lines of code, and I get a message there that says the file is too large. I then tried passing to matlabFunction( ), "Sparse", true, to try to get a sparse numerical Jacobian function file, but I still get the message in the numerical file that the code is too complex to analyze.
What can I do from here?
My goal is to successfully get a numerical Jacobian function file, then evaluate it to get a numerical Jacobian, and then find its eigenvalues using eig( ).
Thanks in advance,
댓글 수: 6
Torsten
2025년 4월 28일
If your ODE system is that complicated, you should completely avoid symbolic computations. Set up everything numerically right from the start - then you won't run into these problems you describe.
Maybe someone can help how to do this, but without at least knowing the mathematical model you try to simulate, it's almost impossible.
채택된 답변
Matt J
2025년 4월 27일
편집: Matt J
2025년 4월 27일
Maybe just compute the Jacobian numerically, by finite differences? If the analytical expressions for the Jacobian are that massive, I don't see how you can be any more confident in the numerical accuracy of the analytical derivative than a finite difference derivative.
추가 답변 (1개)
Walter Roberson
2025년 4월 28일
Use children() to get a 6 x 6 cell array (or simply loop over the contents of the array); matlabFunction() each one seperately .
The time taken to use matlabFunction 'optimize' is roughly exponential in the size of the expression, so separating the expressions can help a lot.
If necessary, you can use children() on the individual expressions, if you are careful about how you put the pieces back together again.
댓글 수: 13
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!