try:
x=3.14;
cmd=['/path/to/program/./test ',num2str(x)];
[status,cmdout]=system(cmd)
and '/path/to/program/' looks strange -- is test really located in /path/to/program/ ?
Pregunta
I wrote a simple C program which takes a command line argument and displays that argument:
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[]){
if(argc<2){return 0;}
else{
double x=atof(argv[1]);
printf("%f\n",x);
return 0;
}
}
Now I want to run this program from within Matlab using the system() function:
>> x=3.14;
>> cmd=['/path/to/program/./test',x]
cmd =
/path/to/program/./test
>> [status,cmdout]=system(cmd)
status =
127
cmdout =
/bin/bash: /path/to/program/./test: No such file or directory
This doesn't seem to work when I try it. I really don't know how to solve this. I'm using a Mac. Thanks in advance.
Solución
try:
x=3.14;
cmd=['/path/to/program/./test ',num2str(x)];
[status,cmdout]=system(cmd)
and '/path/to/program/' looks strange -- is test really located in /path/to/program/ ?