How to pass binary values to mex
2 次查看(过去 30 天)
显示 更早的评论
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
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!