double

Convert symbolic matrix to MATLAB numeric form

r = double(S)

Description

r = double(S) converts the symbolic object S to a numeric object r.

Input Arguments

 S Symbolic constant, constant expression, or symbolic matrix whose entries are constants or constant expressions.

Output Arguments

 r If S is a symbolic constant or constant expression, r is a double-precision floating-point number representing the value of S. If S is a symbolic matrix whose entries are constants or constant expressions, r is a matrix of double precision floating-point numbers representing the values of the entries of S.

Examples

Find the numeric value for the expression $\frac{1+\sqrt{5}}{2}$:

double(sym('(1+sqrt(5))/2')))
1.6180

Find the numeric value for the entries of this matrix T:

a = sym(2*sqrt(2));
b = sym((1-sqrt(3))^2);
T = [a, b; a*b, b/a];
double(T)
ans =
2.8284    0.5359
1.5157    0.1895

Find the numeric value for this expression. By default, double uses a new upper limit of 664 digits for the working precision and returns the value 0:

x = sym('((exp(200) + 1)/(exp(200) - 1)) - 1');
double(x)
ans =
0

To get a more accurate result, increase the precision of computations:

digits(1000)
double(x)
ans =
2.7678e-87

expand all

Tips

• The working precision for double depends on the input argument. It is also ultimately limited by 664 digits. If your computation requires a larger working precision, specify the number of digits explicitly using the digits function.