one input in mex is not read correctly
Afficher commentaires plus anciens
This is the code for mex file I created. mex file reads one input matrix I perfectly fine. but the values of other input matrix X are not correct.. I am not getting what is the issue.. I have attached the mat file for X(A.mat) and I(I.mat). the input function call pattern is mex name(1,2,4,3,3,I',A);
void IDWT(double z[5],float X[20][4], double row,double col, double of,double nv,double S, double I[9][8])
{
for (i = 0; i < 20; i++){
for( j = 0 ; j <4 ; j++ ){
printf("%f-", X[i][j]);}
printf("\n");
}
for (i = 0; i < 9; i++){
for( j = 0 ; j <8 ; j++ ){
printf("%f-", I[i][j]);}
printf("\n");
}
printf("\n");
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
//DECLARING ALL THE ARGUMENTS
double row; double col; double of; double nv; double S; double *I; float *X;
//DOUBLE PRECISION CORRESPONDANCE OF THE OUTPUT
double *Z;
row = mxGetScalar(prhs[0]);
col = mxGetScalar(prhs[1]);
of = mxGetScalar(prhs[2]);
nv = mxGetScalar(prhs[3]);
S = mxGetScalar(prhs[4]);
// SPECIAL CASE FOR ARRAYS
I= mxGetPr(prhs[5]);
X = mxGetPr(prhs[6]);
plhs[0] = mxCreateDoubleMatrix(1,nv,mxREAL); // I put nv=5 for input,keeping in mind the size of output
Z = mxGetPr(plhs[0]);
IDWT(Z,X,row,col, of, nv, S, I);
}
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!