How to load a mat file in mex with input string as file path?

조회 수: 2 (최근 30일)
Hariprasad
Hariprasad 2014년 10월 27일
편집: Hariprasad 2014년 10월 27일
I'm writing a C code for Mex where in I have to load about 1000 mat files. The names of mat files are stored in cell array in another mat file. The input to the main function has the path from where I have to load this cell array mat file and then later iteratively I have to load each of the 1000 mat files which are saved in the same path. How do I load the mat file when I have the path as a char variable in Mex. So far this is my code: -
char *srcpath;
srcpath = mxCalloc( ((mxGetM(prhs[2]) * mxGetN(prhs[2])) + 1), sizeof(char));
mxGetString(prhs[0], Type, ((mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1));
How do I proceed further? Like how can I do
load([srcpath,'datainfo.mat']);
  댓글 수: 2
Jan
Jan 2014년 10월 27일
Do you really have to do this in C? It is so much easier in Matlab.
Hariprasad
Hariprasad 2014년 10월 27일
편집: Hariprasad 2014년 10월 27일
This is just the start of my code. The 1000 mat files have loads of data in them which undergo a lot of processing hence I'm using mex. Its the concatenation of srcpath and 'datainfo.mat' that has kept me holding.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by