Help to get decimal answers in Matlab?

Thread Starter

Siddharth Sigroha

Joined Aug 2, 2015
1
when i solve this equation (solve((x^3-x^2-20*x+43)==0,x)) using syms x i get a typical answer in form of rational and powers. How do i convert it into decimal points. Tried using vpa(x) but it shows ans x = x.
 

Attachments

GopherT

Joined Nov 23, 2012
8,012
when i solve this equation (solve((x^3-x^2-20*x+43)==0,x)) using syms x i get a typical answer in form of rational and powers. How do i convert it into decimal points. Tried using vpa(x) but it shows ans x = x.
Since your answer is a function (that is true for ALL values of x) rather than a single value. If you want one decimal value, you must mean one decimal value for a single value of x. Therefore, you need to find a way to enter the value of x that you are concerned with.
 

Papabravo

Joined Feb 24, 2006
12,702
IIRC there is a format setting for exact answers or approximate answers. What you have is exact answers, and what you want is approximate answers.
 

John_2016

Joined Nov 23, 2016
55
Hi Sidharth Sigroha

do you mean this:

roots([1 -1 -20 43])
=
-4.889312760998691 + 0.000000000000000i
2.944656380499344 + 0.351697080806493i
2.944656380499344 - 0.351697080806493i

 
Top