TEXTWIDTH

Maximum number of characters in an output line

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.

Description

The environment variable TEXTWIDTH determines the maximum number of characters in one line of screen output.

Possible values: Positive integer smaller than 231.

Output is broken into several lines if it needs more than TEXTWIDTH characters per line.

Deletion via the statement “delete TEXTWIDTH” resets TEXTWIDTH to its default value. Executing the function reset also restores the default value.

The minimal value of TEXTWIDTH is 10.

TEXTWIDTH is set to its maximum value 231 - 1 when printing to a text file using fprint. Thus, no additional line breaks occur in the output.

TEXTWIDTH does not influence the typesetting of expressions which is available for some user interfaces of MuPAD®.

TEXTWIDTH is set to the new number of available columns every time the console is resized.

Examples

Example 1

Set the maximum number of characters in one line of screen output to 15:

TEXTWIDTH := 15:

Restore TEXTWIDTH to its default value:

delete TEXTWIDTH

Example 2

The following procedure adds empty characters to produce output that is flushed right:

myprint := proc(x) local l; begin
             if domtype(x) <> DOM_STRING then
                x := expr2text(x);
             end_if;
             l := length(x);
             print(Unquoted, _concat(" " $ TEXTWIDTH - l, x))
           end_proc:
myprint("hello world"):  myprint(30!):  myprint("bye bye"):
                                                                hello world
                                          265252859812191058636308480000000
                                                                    bye bye
delete myprint: