Thursday, November 20, 2008

File output and input in Matlab and C

Save matlab workspace variables to a text file
save('filename','variable_name','-ASCII');

Scan this file into a C program
int k1;
FILE *filename;
filename = fopen("filename","r");
for (k1 = 0; k1 < size; k1++)
fscanf(filename, "%f ", &var[k1]);
fclose(filename);

No comments: