| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
system('command')
[status, result] = system('command')
system('command') calls upon the operating system to run command, for example dir or ls or a UNIX[1] shell script, and directs the output to the MATLAB software. If command runs successfully, ans is 0. If command fails or does not exist on your operating system, ans is a nonzero value and an explanatory message appears.
[status, result] = system('command') calls upon the operating system to run command, and directs the output to MATLAB. If command runs successfully, status is 0 and result contains the output from command. If command fails or does not exist on your operating system, status is a nonzero value and result contains an explanatory message.
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 returns the error: ??? 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
! (exclamation point), computer, dos, perl, unix, winopen
Running External Programs in the MATLAB Desktop Tools and Development Environment documentation
[1] UNIX is a registered trademark of The Open Group in the United States and other countries.
![]() | syntax | tan | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |