Mex: How to read filepath from matlab-function?
Ältere Kommentare anzeigen
Hello, i want to send from my matlab-function a path of a file to my mex-function. Then in my mex-function i want to open the file. Sorry for that quite simple question but i m quite a beginner in mex and c.
Heres my try to solve the problem. If someone could give me an advise how i could solve this i would be very grateful. Many thanks!
//In my matlab-script i call the mex-function like this:
data= myMex("c:\\testdata.dat");
//Then in my mex-file i try to use the argument filepath
mxChar *filename;
mxArray *xData;
FILE * pFile;
xData = prhs[0];
filename = mxGetChars(xData);
pFile= fopen(filename, "rb"); // result: file could not be opened
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!