conversion of dot C file to dot mat file
Show older comments
Hi..... Is there any possibility to convert dot C file to matlab file(dot mat) ? Is there any such cross compiler present ?
Answers (2)
Sachin Ganjare
on 12 Sep 2012
From MATLAB documentation:
#include "mat.h" // matlabroot\extern\include
void main(){
double array[] = {1,2,3,4,5,6,7,8,9};
mxArray *a = mxCreateDoubleMatrix(9, 1, mxREAL);
memcpy(mxGetPr(a), array, 9 * sizeof(double));
MATFile *matfile = matOpen("matfile.mat", "w");
matPutVariable(matfile, "data", a);
}
You also need to link with libmat.lib, which is somewhere like :matlabroot\extern\lib\win32\microsoft\msvc60.
Hope this helps!!!!
Walter Roberson
on 12 Sep 2012
0 votes
There is no .C to .m cross-compiler. There is, though, an interface to allow C and C++ code to call or be called from MATLAB.
Categories
Find more on Debugging and Improving Code in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!