illegal use of type name mxArray
Mostrar comentarios más antiguos
Hello,
When I compile the following code, I get an error from the compiler:
int count_OK;
double *Gain_final = NULL;
double *freq_final = NULL;
// value of count_OK is defined
Gain_final = (double*)malloc(count_OK*sizeof(double));
freq_final = (double*)malloc(count_OK*sizeof(double));
// Fill arrays of variable size Gain_final, phase_final, freq_final
x_ptr_freq_final = mxCreateDoubleMatrix(1, count_OK, mxREAL);
memcpy(mxGetPr(x_ptr_freq_final), freq_final, sizeof(double)*count_OK);
x_ptr_gain_final = mxCreateDoubleMatrix(1, count_OK, mxREAL);
memcpy(mxGetPr(x_ptr_gain_final), Gain_final, sizeof(double)*count_OK);
mxArray *prhs[2] = {x_ptr_freq_final, x_ptr_gain_final};
The error of the compiler is the following:
Error time2freq.c: 430 illegal use of type name `mxArray'
Error time2freq.c: 430 unknown size for type `incomplete struct mxArray_tag defined at C:\Program Files (x86)\Matlab_R2010BSP2\extern\include\matrix.h 298'
Error time2freq.c: 430 operands of * have illegal types `incomplete struct mxArray_tag defined at C:\Program Files (x86)\Matlab_R2010BSP2\extern\include\matrix.h 298' and `incomplete struct mxArray_tag defined at C:\Program Files (x86)\Matlab_R2010BSP2\extern\include\matrix.h 298'
Error time2freq.c: 430 illegal expression
Error time2freq.c: 430 lvalue required
Warning time2freq.c: 430 possible usage of prhs before definition
Error time2freq.c: 430 syntax error; found `x_ptr_freq_final' expecting `;'
Warning time2freq.c: 430 Statement has no effect
Error time2freq.c: 430 syntax error; found `}' expecting `;'
Error time2freq.c: 431 illegal use of type name `mxArray'
When the arrays Gain_final and freq_final are not defined dynamically with malloc, everything works. But as the size of these arrays change, I need to use malloc.
Thank you for your help if you have any idea:)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre C Shared Library Integration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!