Hi,
I think the issue is raised in your switch statement when you open a file. You have a return in there, which leads to terminating the mex file without assigning the output variables. Change the return to a break and it should work.
In addition these line should generate a SegV:
plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
validity_out = mxGetPr(plhs[1]);
validity_out[1] = validity;
Since validity_out[1] will access the second field in an array with one field only. This should be
validity_out[0] = validity;
The same applies on timestamp.
You dont need to apply mxFree on the xx_out variables. Since the weren't allocated woth mxMalloc and in addition they get deleted automatically when the mex function is finshed running.
Best Answer