MATLAB Answers

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

6 views (last 30 days)
Hariprasad
Hariprasad on 27 Oct 2014
Edited: Hariprasad on 27 Oct 2014
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 Comments
Hariprasad
Hariprasad on 27 Oct 2014
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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!