There might not be a way if ‘x’ value changes . But if ‘x’ value is fixed you can get the desired result with the help of ‘latex()’ and ‘sym’ functions.
Here are the links for the above mentioned functions.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!