Other class conversions are possible as well for instance, to change it into a string use the 'char' function. To make MATLAB change this back into a 'double', type: Here, of course, MATLAB would normally return 0.5. For example, to represent the number 0.5 as a fraction, you can use: The difference between symbolic numbers and normal MATLAB numbers is that, if possible, MAPLE will keep the symbolic number as a fraction, which is an exact representation of the answer. Symbolic numbers can also be declared using the syntax a(3) = sym('number').
> a(3) = 1 %would normally be class 'double' If you try to add a number into a symbolic array it will automatically turn it into a symbolic number.
This section helps explain how to declare them. Symbolic numbers allow exact representations of fractions, intended to help avoid rounding errors and representation errors. The following creates three symbolic variables, a b and c. By default, the symbolic variables created have the same names as the arguments of the 'syms' function. Symbolic variables can also be declared many at a time using the 'syms' function. You can create arrays of symbolic expressions like everything else: You can declare a single symbolic variable using the 'sym' function as follows. The MATLAB student version comes with a copy of the symbolic math toolbox. The symbolic math toolbox takes some time to initialize, so if nothing happens for a few seconds after you declare your first symbolic variable of the session, it doesn't mean you did anything wrong. Rather, it is useful as a supplement to provide functions which MATLAB, as a numerical engine, has difficulty with. It is important to remember that MAPLE is not a numeric engine, which means that there are certain things it doesn't let you do that MATLAB can do. The toolbox simply calls the MAPLE kernel with whatever symbolic expressions you have declared, and then returns a (usually symbolic) expression back to MATLAB. The symbolic toolbox is a bit difficult to use but it is of great utility in applications in which symbolic expressions are necessary for reasons of accuracy in calculations. Introduction to the Symbolic Math Toolbox
5.1 Solving Algebraic Equations With a Single Variable.4.2 Using Functions with Symbolic Matrices as Inputs.
You can share your symbolic work with other MATLAB users as live scripts or convert them to HTML, Word, LaTex, or PDF documents. Your computations can be performed either analytically or using variable-precision arithmetic, with the results displayed in mathematical typeset. You can perform dimensional computations and convert between units. Symbolic Math Toolbox lets you analytically perform differentiation, integration, simplification, transforms, and equation solving. The toolbox provides functions in common mathematical areas such as calculus, linear algebra, algebraic and differential equations, equation simplification, and equation manipulation. In the MATLAB ® Live Editor, you can get next-step suggestions for symbolic workflows. You can create, run, and share symbolic math code. Symbolic Math Toolbox™ provides functions for solving, plotting, and manipulating symbolic math equations.