system - Execute operating system command and return result

Syntax

system('command')
[status, result] = system('command')

Description

system('command') calls upon the operating system to run command, for example dir or ls or a UNIX® 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.

Examples

On a Windows system, display the current directory by accessing the operating system.

[status currdir] = system('cd')
status =
    0
currdir =
    D:\work\matlab\test

See Also

! (bang), computer, dos, perl, unix, winopen

Running External Programs in the MATLAB Desktop Tools and Development Environment documentation

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS