one input in mex is not read correctly
이전 댓글 표시
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);
}
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!