Filter löschen
Filter löschen

How to speed up my code (computing jacobian)

7 Ansichten (letzte 30 Tage)
M. Wang
M. Wang am 15 Jun. 2024
Kommentiert: Torsten am 15 Jun. 2024
My input are a lot of linear expressions such as x1+x2, x2+3*x3 etc. How to speed up my code as follows
allvars = symvar(input); % There are about 1000 LINEAR expressions in 'input'
J = jacobian(input, allvars);
  2 Kommentare
Torsten
Torsten am 15 Jun. 2024
You shouldn't work symbolically with about 1000 expressions. A numerical approach is the way to go.
M. Wang
M. Wang am 15 Jun. 2024
Thanks for your advice! Is there any approach without loss of precision?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 15 Jun. 2024
Bearbeitet: Matt J am 15 Jun. 2024
You can use equationsToMatrix to obtain the Jacobian. Depending on what you are doing, you might then convert the matrix to double so you can reuse and do more rapid numerical manipulations with it.
  1 Kommentar
Torsten
Torsten am 15 Jun. 2024
Assuming that "input" only consists of linear expressions, not only a lot.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2011a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by