Thursday, May 05, 2011

[Matlab] Interact with operating system command

Problem

When using system() to execute the operating system command, the command requires the user input for further operations, but system() does not return any message to inform the user, causing the Matlab script to hang.

Solution

Use the option '-echo' to forces the output to the Command Window, allowing the user to interact with the operating system command when necessary

system(cmd, '-echo')

Reference

Matlab Help for function system()