Convert objects into character strings
MuPAD® notebooks will be removed in a future release. 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.
If the function is called without arguments, then an empty character string is created. If more than one argument is given, the arguments are interpreted as an expression sequence and are converted into a single character string.
Like most other MuPAD® function,
its arguments before the conversion.
If strings occur in
they will be quoted in the result.
Expressions are converted into character strings:
expr2text(a + b)
expr2text quotes strings.
Note that the quotation marks are preceded by a backslash when they
are printed on the screen:
If more than one argument is given, the arguments are treated as a single expression sequence:
expr2text(a, b, c)
If no argument is given, an empty string is generated:
expr2text evaluates its arguments:
a := b: c := d: expr2text(a, c)
expr2text(hold(a, c)); delete a, c:
Here is another example:
expr2text((a := b; c := d)); delete a, c:
e := expr2text(hold((a := b; c := d)))
The last string contains a newline character “\n”.
Unquoted to expand this into a new line:
(a := b; c := d)
T := newDomain("T"): e := new(T, 1): e; print(e): expr2text(e)
"print" slot exists, it will be called
expr2text to generate the output:
T::print := proc(x) begin _concat("foo: ", expr2text(extop(x))) end_proc: e; print(e): expr2text(e)
If you want
expr2text to generate an output
differing from the usual output generated by
T::expr2text := proc(x) begin _concat("bar: ", expr2text(extop(x))) end_proc: e; print(e): expr2text(e)
Any MuPAD object
When processing a domain element
tries to call the
"expr2text" method of the corresponding
T. If it exists,
called and the result is returned. If no
expr2text tries to call the
in the same way. If no
"print" method exists either,
generate a default output. Cf. Example 4.
"expr2text" method or a
may return an arbitrary MuPAD object, which will be processed
The returned object must not contain the domain element
a sub-object. Otherwise, the MuPAD kernel runs into infinite
recursion and emits an error message.
For expressions, the result
expr2text always coincides with the
output produced by
expr2text is computed by the second
operand of the function environment.