Access an entry of the history table
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.
history(n) returns the
entry of the history table.
history() returns the index of the most
recent entry in the history table.
The commands that are entered interactively in a MuPAD® session,
executed in a procedure, or read from
a file, as well as the resulting MuPAD outputs are stored in an internal
data structure, the history table.
the index of the most recent entry in the history table. At interactive
level, this is the number of commands that have been entered since
the start of the session or the last restart.
history(n) returns the
entry in the history table in form of a list with two elements. The
first element of this list is a MuPAD command, and the second element
is the result of this command returned by MuPAD. The order of the
entries in the history table is such that larger indices correspond
to more recent entries.
the result entries from the history table. The call
last(n) is equivalent to
history ( history() - n +
1)  at interactive level.
The environment variable
HISTORY determines the maximal number
of history entries that are stored at interactive level. The default
20. Only the most recent entries are kept
in memory. Thus valid arguments for
all integers between
history() - HISTORY + 1 and
history(). All other integers lead to an error message.
Commands and their results are stored in the history table even if the output is suppressed by a colon. See Example 1.
Compound statements, such as
case branching instructions, and procedure
stored in the history table as a whole at interactive level. See the
help page of
Commands appearing on the same input line lead to separate entries in the history table if they are separated by a colon or a semicolon. In contrast, a statement sequence is regarded as a single command (see Example 3).
Commands that are read from a file via
read are stored in the history table,
and at last the
read command is stored
in the history table (because the
read command is finished foremost after
reading the file). However, if the option
used, then a separate history table is in effect within the file,
and the commands from the file do not appear in the history table
of the enclosing context.
Note that every call of
the history table and possibly erases the earliest history entry.
Every procedure has its own
local history table. However, the entries of this table cannot be
last). The command
refers to the history table at interactive level.
The index of the most recent entry in the history table increases
by one for each entered command, also by
Note that every command is stored in the history table, whether its
output is suppressed by a colon or not:
history(); sqrt(1764); history(): history()
3 42 6
history ( history() ) returns a list with
two elements. The first element is the last command, and the second
element is the result returned by MuPAD, which is equal to
int(2*x*exp(x^2), x); history(history()), last(1)
The following command returns the next to last command and its result:
history(history() - 1)
A restart cleans up the history table:
The output of the command
depends on the number of commands in your MuPAD startup file
a should be
a := 0: a
1 is assigned to
a := 1: a
history ( history() -2) refers
to the command
a after assigning
the return value of
history is not the new value
a, because the result returned by
not evaluated again:
history(history() - 2)
The following commands create two entries in the history table.
history ( history() -1) returns only
the last command
b:=a, not both commands:
a := 0: b := a: history(history() - 1)
If the commands are entered as a statement
sequence (enclosed in
( )), they create
history ( history() ) picks out the
last command, that is, the statement sequence:
(a := 0; b := a;): history(history())
[(a := 0; b := a), 0]
The last input
A positive integer