Matlab is unable to evaluate very a very long expression
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dominik Hiltbrunner
am 5 Nov. 2021
Bearbeitet: Dominik Hiltbrunner
am 5 Nov. 2021
Attached to this post is a text file containing a very long expression.
I want to evaluate this expression numerically in a Matlab function, i.e. something like this:
function result = (<long lost of all the parameters>)
result = '<this very long expression from the text file>'
end
The computer gets stuck when doing so, not returning a result even after hours of running.
Is there anything I can do to speed up the computation of very long expressions?
2 Kommentare
Stephen23
am 5 Nov. 2021
Note that you should replace all of the ^(1/2) with SQRT.
What sizes are the input arrays?
Are you intentionally using matrix operations instead of array operations everywhere in this code?
Akzeptierte Antwort
Steven Lord
am 5 Nov. 2021
How did you generate this long expression? Did you generate this using Symbolic Math Toolbox? If so consider using matlabFunction to create a function file from this expression (leaving the 'Optimize' option set to its default value of true) and see if the optimization process simplifies the computation of that expression by extracting out some common terms that it can compute once and use repeatedly.
1 Kommentar
Dominik Hiltbrunner
am 5 Nov. 2021
Bearbeitet: Dominik Hiltbrunner
am 5 Nov. 2021
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!