主题:c++ matlab混合编程问题
This is my M-file:
function [C,h]=const_cont(norm_matrix,circle_num)
[C,h]=contour(norm_matrix,circle_num);
text_handle = clabel(C,h);
Then I compile it in Matlab:
mcc -l const_cont.m
In VC++6.0, I program as
int cont_num[1][1]={10};
mxArray *A = mxCreateDoubleMatrix(11, 11, mxREAL);
mxArray *B= mxCreateDoubleMatrix(1, 1, mxREAL);
memcpy(mxGetPr(A),angular, 11*11*sizeof(double));
memcpy(mxGetPr(B),cont_num, sizeof(double));
mxArray *C_Matrix=NULL,*D=NULL;
const_contInitialize();
mlfConst_cont(2,&C_Matrix,&D,A,B);
int *aa=mxGetPtr(C_Matrix);
But I find aa=NULL.
Then I test it using
int aa=mxGetN(C_Matrix);
int bb=mxGetM(C_Matrix);
I found aa=0, and bb=2.
Actually, aa could not be 0.
So could somebody help me to give me some advise?
function [C,h]=const_cont(norm_matrix,circle_num)
[C,h]=contour(norm_matrix,circle_num);
text_handle = clabel(C,h);
Then I compile it in Matlab:
mcc -l const_cont.m
In VC++6.0, I program as
int cont_num[1][1]={10};
mxArray *A = mxCreateDoubleMatrix(11, 11, mxREAL);
mxArray *B= mxCreateDoubleMatrix(1, 1, mxREAL);
memcpy(mxGetPr(A),angular, 11*11*sizeof(double));
memcpy(mxGetPr(B),cont_num, sizeof(double));
mxArray *C_Matrix=NULL,*D=NULL;
const_contInitialize();
mlfConst_cont(2,&C_Matrix,&D,A,B);
int *aa=mxGetPtr(C_Matrix);
But I find aa=NULL.
Then I test it using
int aa=mxGetN(C_Matrix);
int bb=mxGetM(C_Matrix);
I found aa=0, and bb=2.
Actually, aa could not be 0.
So could somebody help me to give me some advise?