convert the roots from symbolic constants to double in matlab

To convert the roots obtained from symbolic constants to double, you can use the double function in MATLAB. First, use the roots() function to obtain the roots in symbolic constants. Then, convert them to double using the double() function. Here's an example:

main.m
% create a polynomial equation
p = [1 -3 2];

% obtain the roots in symbolic constants
syms x
r = roots(p);
disp(r);

% convert the roots to double
r_double = double(r);
disp(r_double);
186 chars
12 lines

In this example, p is a vector representing a polynomial equation. The roots() function is used to obtain the roots of this equation in symbolic constants, which are stored in variable r. The double() function is used to convert r to double, and the resulting roots are stored in variable r_double. Finally, the roots in double precision are displayed using disp().

gistlibby LogSnag