Main Content

pretty

Pretty-print symbolic expressions

pretty is not recommended. Use live scripts instead for full math rendering. For more information, see What Is a Live Script or Function?

Syntax

Description

pretty(X) prints X in a plain-text format that resembles typeset mathematics in the Command Window. For full math rendering and a more interactive workflow, use live scripts instead. See What Is a Live Script or Function?

example

Examples

collapse all

Pretty-print symbolic expressions in the Command Window.

A = sym(pascal(2))
B = eig(A)
pretty(B)
A =

[1, 1]
[1, 2]


B =
 
3/2 - 5^(1/2)/2
5^(1/2)/2 + 3/2
 
/ 3   sqrt(5) \
| - - ------- |
| 2      2    |
|             |
| sqrt(5)   3 |
| ------- + - |
\    2      2 /

Solve an equation in the Command Window, and then use pretty to represent the solutions in a format similar to typeset mathematics. For better readability, pretty uses abbreviations when representing long expressions.

syms x
s = solve(x^4 + 2*x + 1, x, MaxDegree=3);
pretty(s)
/         -1         \
|                    |
|           2    1   |
|    #2 - ---- + -   |
|         9 #2   3   |
|                    |
|   1         #2   1 |
| ---- - #1 - -- + - |
| 9 #2         2   3 |
|                    |
|        1    #2   1 |
| #1 + ---- - -- + - |
\      9 #2    2   3 /

where

                 /   2       \
         sqrt(3) | ---- + #2 | 1i
                 \ 9 #2      /
   #1 == ------------------------
                    2

         / sqrt(11) sqrt(27)   17 \1/3
   #2 == | ----------------- - -- |
         \         27          27 /

Input Arguments

collapse all

Input, specified as a symbolic number, scalar variable, matrix variable, array, function, matrix function, or expression.

Version History

Introduced before R2006a

expand all