conversion of dot C file to dot mat file

3 views (last 30 days)
Abhijeet Masal
Abhijeet Masal on 12 Sep 2012
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
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
Walter Roberson on 12 Sep 2012
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 C Shared Library Integration 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!