How to pass binary values to mex

2 ビュー (過去 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 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 5 日
To be honest, I am not enthusiastic about rebooting my computer into Windows, doing hours and hours of Windows updates, downloading the Measurement Computing development library, installing a compiler, putting together the pieces of what you posted to try to produce a project, and figuring out how to use a Windows debugger.
James would probably appreciate if you put together a zip of everything together and a link of the Measurement Computing development package.
My personal suspicion is that you could perhaps produce a smaller example that did not call upon the measurement computing routines. And if you were to find that the trimmed example does not produce the same problem, then you would have isolated down to an interaction with MC libraries, which would give you information about what to look for.
A R
A R 2020 年 3 月 5 日
Walter, yes I will try the example with session based interface.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by