Have a trouble while solving system of linear equations!

Hi everybody,
I have met a trouble while I try to solve system of linear equations by Matlab. I used LU decomposition algorithm to code a function to solve the system equations. In fact it worked well when I input data by my self. But when I use syms function in Matlab in my main program to name the variables, and use my own function to solve, it appeared an error, the solution is plenty of number and not correct anymore. I really don't understand that problem likes this
So would you please help me to solve this problem?
Thanks in advanced

 Accepted Answer

Call the function digits() passing in the number of decimal places you want the computation to be carried out to. Call vpa() passing in the result of your computation.
If you want the result to be in double precision, usable in other MATLAB computations, then it is not clear why you would do symbolic calculations. None the less, you can use double() to convert symbolic numbers to double precision.

More Answers (1)

Thanks for your answer! that is really helpful.
Anyway, When i use digit() function, combine with vpa() function to fix that problem the result is still not as good as expected. In other words, i used double() function to covert the symbolic, named the variables, to numeric and the result is the same.
Best regards.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!