| Symbolic Math Toolbox | ![]() |
Symbolic and Numeric Conversions
Consider the ordinary MATLAB quantity
The sym function has four options for returning a symbolic representation of the numeric value stored in t. The 'f' option
returns a symbolic floating-point representation
This is the default setting for sym. That is, calling sym without a second argument is the same as using sym with the 'r' option:
The third option 'e' returns the rational form of t plus the difference between the theoretical rational expression for t and its actual (machine) floating-point value in terms of eps (the floating-point relative accuracy):
The fourth option 'd' returns the decimal expansion of t up to the number of significant digits specified by digits:
The default value of digits is 32 (hence, sym(t,'d') returns a number with 32 significant digits), but if you prefer a shorter representation, use the digits command as follows:
A particularly effective use of sym is to convert a matrix from numeric to symbolic form. The command
generates the 3-by-3 Hilbert matrix:
you can obtain the symbolic (infinitely precise) form of the 3-by-3 Hilbert matrix:
| The subs Command | Constructing Real and Complex Variables | ![]() |
Learn more about the latest releases of MathWorks products: |
| © 1994-2009 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |