Ho to extract an C array from Mex function (pointer to pointer to pointer ; double ***)
이전 댓글 표시
Dear Community,
I've got this problem where I need to interface an old C-algorithm into my new Matlab program.
This C-function needs as one input a double*** array. I allacoate some memory inside the mexFunction via:
double ***rv_solve;
rv_solve = (double ***)mxCalloc(X_SIZE, sizeof(double *));
for (i = 0 ; i < X_SIZE; i++) {
rv_solve[i] = (double **)mxCalloc(Y_SIZE, sizeof(double *));
for (j = 0; j < Y_SIZE; j++)
rv_solve[i][j] = (double *)mxCalloc(Z_SIZE, sizeof(double *));
}
The C-function manipulates this 3D array and I want this array back into my Matlab workspace.
The output gets assigned by
rv_solve_out = (double *)mxGetPr(plhs[2]);
How do I now associate double*** rv_solve with double* rv_solve_out ?
All I found on the web and the documantation is about 1-Dim arrays. I would love to use just 1-Dim arrays and use superindexing, but I need this C-function and it is complicated enough not to rewrite it for 1-Dim inputs.
And probably there is an easy solution, as most times, but I'm just to stupid to find or recognize it.
Thanks in advance.
Cheers Achim
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!