How to pass binary values to mex

9 ビュー (過去 30 日間)
A R
A R 2020 年 3 月 3 日
コメント済み: A R 2020 年 3 月 5 日
Hello, I want to transmit 1x12 binary data to mex file for data transmission
b=70.19
Y = round(b,1);
dec= Y*10;
integers=dec;
temp = integers;
mask = temp < 0;
temp(mask) = 2^12 + temp(mask) ;
a=decimalToBinaryVector(temp, 12);
The output binary values (a) is : 0 0 1 0 1 0 1 1 1 1 1 0
When I pass these values to mex file,
b= mex(a);
I get a different binary value. The output of a is:
1.18870000000000e-320 1.18870000000000e-320 1.00000000000053 1.18870000000000e-320 1.00000000000053 1.18870000000000e-320 1.00000000000053 1.00000000000053 1.00000000000053 1.00000000000053 1.00000000000053 1.18870000000000e-320
mex.c
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
double *a;
int M,N;
double* bb; /* 1xN output matrix */
const mwSize *dims;
a=mxGetData(prhs[0]);
plhs[0] = mxCreateDoubleMatrix(M, N, mxREAL);
bb = mxGetPr(plhs[0]);
analogoutputMatlab(a,bb,N);
}
Why do I get change in binary values? How to pass binary values to mex?
  14 件のコメント
A R
A R 2020 年 3 月 5 日
Walter, yes I will try the example with session based interface.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Find more on C Shared Library Integration in Help Center and File Exchange

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by