| Contents | Index |
system('command')
[status, result] = system('command')
[status,result] = system('command','-echo')
system('command') calls the operating system to run the given command and directs the output to the MATLAB software. The command executes in a system shell, which might not be the shell from which you launched MATLAB.
[status, result] = system('command') returns completion status to the status variable and returns the result of the command to the result variable.
[status,result] = system('command','-echo') also forces the output to the Command Window.
The ampersand, &, character has special meaning. For console programs this causes the console to open. Omitting this character causes console programs to run iconically. For GUI programs, appending this character causes the application to run in the background. MATLAB continues processing.
This function is interchangeable with the dos and unix functions.
Note Running system on a Microsoft Windows platform with a command that relies on the current folder fails when the current folder is specified using a UNC pathname because DOS does not support UNC pathnames. When this happens, MATLAB displays: Error using system DOS commands may not be executed when the current directory is a UNC pathname To work around this limitation, change the folder to a mapped drive prior to running system or a function that calls system. |
On a Windows system, display the current folder by accessing the operating system.
[status currdir] = system('cd')
status =
0
currdir =
D:\work\matlab\test
On a UNIX system, if you redirect stdin in the script and type at the keyboard while the script executes, MATLAB does not display the type-ahead characters.
[a,b] = system('cmd < /dev/null');! (exclamation point) | computer | dos | perl | unix

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |