%% Display Symbolic Results in Floating-Point Format
% Display symbolic results in floating-point output format, that is the short, fixed-decimal format with 4 digits after the decimal point.
% Create a quadratic equation.

syms x
eq = x^2 - 2e3/sym(pi)*x + 0.5 == 0

% Find the solutions of the equation using solve.

sols = solve(eq,x)

% Set the 'FloatingPointOutput' preference to true. Display the quadratic equation and its solutions in floating-point format.

sympref('FloatingPointOutput',true);
eq
sols

% The floating-point format displays each symbolic number in the short, fixed-decimal format with 4 digits after the decimal point. Setting the 'FloatingPointOutput' preference does not affect the floating-point precision in a symbolic computation. To compute symbolic numbers using floating-point arithmetic, use the vpa function.
% Now restore the default value of 'FloatingPointOutput' by specifying the 'default' option. Compute the floating-point approximation of the solutions in 8 significant digits using vpa.

sympref('FloatingPointOutput','default');
sols = vpa(sols,8)

%
% Copyright 2018 The MathWorks, Inc.