Azzera filtri
Azzera filtri

Guidance in writing mexFunction for convert.c

1 visualizzazione (ultimi 30 giorni)
I have data in CSV (comma seperated value) format, i need it in the libsvm format. I found a c code to do it:
But i want to call this in matlab. So i need to include a mexFunction in convert.c , could anyone guide me/help me out with writing this function?

Risposta accettata

James Tursa
James Tursa il 23 Dic 2013
Try putting this at the top of the file and then mex it:
// One input argument: The Filename
int main(int argc, char **argv);
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
int argc = 2;
char *argv[2];
if( nrhs == 1 && mxIsChar(prhs[0]) ) {
argv[1] = mxArrayToString(prhs[0]);
} else {
mexErrMsgTxt("Expected one input, the filename");

Più risposte (0)


Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by