| MATLAB Function Reference | ![]() |
Run operating system command and return result
Description
system('command')
calls upon the operating system to run command, for example dir or ls, and directs the output to MATLAB. 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, result is an empty matrix, and an explanatory message appears.
Examples
Display the current directory by accessing the operating system.
MATLAB displays the current directory and shows that the command executed correctly because ans is 0.
Similarly, run the operating system pwd command and assign the current directory to curr_dir.
See Also
! (exclamation point), dos, perl, unix
| symvar | tan | ![]() |