how to create C-mex function

1 visualización (últimos 30 días)
Michal Kvasnicka
Michal Kvasnicka el 3 de En. de 2013
How to create suitable mex gateway function coresponduing to the following C function (decimal to binary conversion)?
void deci2bin( int x, int n, double* output){
double *temp;
int i;
temp = (double *)mxMalloc(sizeof(double)*n);
i=0;
while(x>=0 && i<n){
temp[i] = x%2;
i++;
}
for(i=0;i<n;i++)
output[i] = temp[n-1-i];
}
Thanks in advance for any help.
  1 comentario
Walter Roberson
Walter Roberson el 3 de En. de 2013
Have you considered looking at the source of dec2bin() and removing the char() and the +'0' from the algorithm given there?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by