This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

pretty

Prettyprint symbolic expressions

pretty is not recommended. Use Live Scripts instead. Live Scripts provide full math rendering while pretty uses plain-text formatting. See What Is a Live Script or Function? (MATLAB)

Syntax

pretty(X)

Description

example

pretty(X) prints X in a plain-text format that resembles typeset mathematics. For true typeset rendering, use Live Scripts instead. See What Is a Live Script or Function? (MATLAB)

Examples

collapse all

Pretty print symbolic expressions.

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 this equation, and then use pretty to represent the solutions in the 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 /

Introduced before R2006a