Help to get decimal answers in Matlab?

Discussion in 'Programmer's Corner' started by Siddharth Sigroha, Aug 2, 2015.

  1. Siddharth Sigroha

    Thread Starter New Member

    Aug 2, 2015
    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.
  2. GopherT

    AAC Fanatic!

    Nov 23, 2012
    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.
  3. Papabravo


    Feb 24, 2006
    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.