الثلاثاء، 24 ديسمبر 2013

Pass Matlab parameters to a C program

I wrote a simple C program which takes a command line argument and displays that argument:

#include #include 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];[status,cmdout]=system(cmd)

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.


View the original article here

ليست هناك تعليقات:

إرسال تعليق