I have quite a big 2D vector of data of results that I want to write into a mat file. I'm quite new to C++ and I read some tutorials on how to use the MAT-File APIs and I understood the syntax must be something of the sort:
MATFile *pmat;
vector<double> data{....};
pmat=matOpen("ResultLog.mat", "w");
mxArray *A;
A=mxCreateDoubleMatrix(1, columns, mxREAL);
memcpy(mxGetPr(A), data, columns * sizeof(double));
matPutVariable(pmat, "NameOfDataVariable", A);
matClose(pmat);
mxDestroyArray(A);
My problem is that since I have quite some data to log I would really like to put it into a loop. However how would I be able to change the NameOfDataVariable for each loop ? Or do I have to enter each row of data into the mat file separately ? Like I said I'm quite new to this so Im sorry if its a silly question. Does anyone have any suggestions?