How to convert an expression to a function with lossless precision?
Mostrar comentarios más antiguos
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 comentarios
Ameer Hamza
el 27 de Sept. de 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
el 27 de Sept. de 2020
Chenguang Yan
el 27 de Sept. de 2020
Ameer Hamza
el 27 de Sept. de 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.
Respuesta aceptada
Más respuestas (2)
madhan ravi
el 27 de Sept. de 2020
vpa(f_func(sym(sol1), sym(sol2)))
3 comentarios
Chenguang Yan
el 27 de Sept. de 2020
madhan ravi
el 27 de Sept. de 2020
When you use matlabFunction() , it converts it into double precision, why not use subs()?
Chenguang Yan
el 27 de Sept. de 2020
Chenguang Yan
el 27 de Sept. de 2020
Editada: Chenguang Yan
el 27 de Sept. de 2020
0 votos
Categorías
Más información sobre Conversion Between Symbolic and Numeric en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!