Execute a command of the operating system
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.
system("command") executes a command of the
operating system or a program, respectively.
!command is equivalent to
!command will suppress output of its
!command is allowed during interactive
input only, not when reading MuPAD® input from a file. "
must be the first character on the input line.
system is not available in all MuPAD versions.
If not available, a call to
system results in the
following error message:
Error: Function not available for this client [system].
system("command") sends the command to the
operating system. E.g., this command may start another application
program on the computer. The return value 0 indicates
that the command was executed successfully. Otherwise, an integer
error code is returned which depends on the operating system and the
If the called command writes output to
stderr on UNIX® systems,
the output will go to the MuPAD
on the standard output channel will be inserted in the command's output,
but are not accessible programmatically.
On a UNIX system, the
date command is executed.
The command output is printed to the screen, the error code 0 for
successful execution is returned to the MuPAD session:
errorcode := system("date"):
Fri Sep 29 14:42:13 MEST 2000
date command is called with the command
'+%m' in order to display the current
errorcode := system("date '+%m'"):
Missing the prefix
'+' in the command line
date and therefore
an error code. Note that the error output goes to
system("echo communication example > comm_file"): ftextinput("comm_file")
system("rm -f comm_file"):
A command of the operating system or a name of a program as a MuPAD character string
"error code": an integer.