In MATLAB itself, it is very easy to call system commands, such as the following:
>> system('ls');
yprime.c yprime.mexa64
(Note: using Ubuntu)
From C(++) programs, I can execute system commands using std::system
:
#include <cstdlib>
int main()
{
std::system("ls");
}
But how can I execute system commands from MATLAB Mex programs?
#include <cstdlib>
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
std::system("ls");
}
^^The above compiles, but doesn't output anything to screen when run.