Why did Matlab performance massively decrease for basic arithmetic operations from Matlab R2014b to 2015 and 2017 version?
11 Kommentare
Akzeptierte Antwort
"In a first step to make the code more manageable I found repeating patterns and replaced them."
If you use matlabFunction() with the 'file' option naming a file, then by default 'Optimize' is true for that case, and MATLAB will spend time looking for repeated computations and making appropriate temporary variables.
The resulting code is not typically all that easy to read, but it does tend to be about as efficient as you could get. (Well, other than the fact that it does not always optimize calculations of .^ to higher integer powers as best possible.)
The drawback of this is that it can take a fair bit of time. I have seen it take over an hour for longer expressions. For a calculation such as you describe it would not surprise me if it would take over an hour.
The revised calculation is equivalent algebraically, but not numerically. Numerically,
A + B*C + D
is not the same as
A + D + B*C
However, when you are using symbolic expressions, the order that it uses internally is based upon some arbitrary sorting rules that are difficult to work out, so the order is already numerically suspect even if you do not turn on optimization.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!