How to convert an expression to a function with lossless precision?
Afficher commentaires plus anciens
I use matlabFunction to convert an expression to an anonymous function, but the convertion of matlabFunction has a loss of precision. Is there a lossless conversion method? If not, is there any conversion method to improve accuracy?

4 commentaires
Ameer Hamza
le 27 Sep 2020
Can you give an example of expression, sol1, and sol2? It will be easier if you can share the code in the text format instead of attaching it as an image.
Chenguang Yan
le 27 Sep 2020
Chenguang Yan
le 27 Sep 2020
Ameer Hamza
le 27 Sep 2020
As Walter mentioned in his answer, you will lose precision once you convert from symbolic maths to finite-precision. To get exact results, you must stick to variable precision or symbolic mathematics.
Réponse acceptée
Plus de réponses (2)
madhan ravi
le 27 Sep 2020
vpa(f_func(sym(sol1), sym(sol2)))
3 commentaires
Chenguang Yan
le 27 Sep 2020
madhan ravi
le 27 Sep 2020
When you use matlabFunction() , it converts it into double precision, why not use subs()?
Chenguang Yan
le 27 Sep 2020
Chenguang Yan
le 27 Sep 2020
Modifié(e) : Chenguang Yan
le 27 Sep 2020
0 votes
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!