This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Display of trees

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


output::tree(Tree, <indentdepth, <charlist>, <Small>>)


output::tree displays trees given as specially MuPAD® lists.

The first object of the list is the root of the tree. All further objects are nodes or subtrees of the tree. A subtree is again a special list (as described), and any other MuPAD object will be interpreted as node of the tree.

The elements of the tree will be printed by MuPAD, when the tree will be displayed, so it's recommended to use strings as objects or objects with a well defined display.

The return value is a string that contains all chars to display the tree. With functions print and fprintand the option Unquoted the tree can be displayed.

The parameter charlist is a list with five characters. The default value is ["|", "+", "-", „", " "]. The characters have the following meaning (described in the order of the list).

The vertical lines of the tree, the connection between vertical and horizontal line (i.e., an arm, but not the last arm), an arm (vertical line), the last connection to an arm in a subtree, a char between an arm and the description of the arm.


Example 1

output::tree displayes special nested lists as trees:

TREE := ["a1", "a2", ["b1", "b2", ["c1", "c2"], "b3"],
               ["d1", "d2", "d3"]]:
print(Unquoted, output::tree(TREE))
+-- a2
+-- b1
|   |
|   +-- b2
|   |
|   +-- c1
|   |   |
|   |   `-- c2
|   |
|   `-- b3
`-- d1
    +-- d2
    `-- d3
print(Unquoted, output::tree(TREE, 3, Small)):
+- a2
+- b1
|  +- b2
|  +- c1
|  |  `- c2
|  `- b3
`- d1
   +- d2
   `- d3

The chars can be defined by the user:

print(Unquoted, output::tree(TREE, 6, ["|", "|", ".", "\\", " "])):
|.... a2
|.... b1
|     |
|     |.... b2
|     |
|     |.... c1
|     |     |
|     |     \.... c2
|     |
|     \.... b3
\.... d1
      |.... d2
      \.... d3



The tree, given as a special list


Indent depth for each subtree


The chars that illustrate the tree structure



Suppresses the display of a space line between every tree entry to reduce the height of the tree

Return Values

String object to display

See Also

MuPAD Functions

Was this topic helpful?