How to pass binary values to mex
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 5 de Mzo. de 2020
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.
Respuestas (0)
Ver también
Categorías
Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!