How to convert an expression to a function with lossless precision?
Show older comments
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 Comments
Ameer Hamza
on 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
on 27 Sep 2020
Chenguang Yan
on 27 Sep 2020
Ameer Hamza
on 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.
Accepted Answer
More Answers (2)
madhan ravi
on 27 Sep 2020
vpa(f_func(sym(sol1), sym(sol2)))
3 Comments
Chenguang Yan
on 27 Sep 2020
madhan ravi
on 27 Sep 2020
When you use matlabFunction() , it converts it into double precision, why not use subs()?
Chenguang Yan
on 27 Sep 2020
Chenguang Yan
on 27 Sep 2020
Edited: Chenguang Yan
on 27 Sep 2020
0 votes
Categories
Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!