how to create C-mex function

2 次查看(过去 30 天)
Michal Kvasnicka
Michal Kvasnicka 2013-1-3
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 个评论
Walter Roberson
Walter Roberson 2013-1-3
Have you considered looking at the source of dec2bin() and removing the char() and the +'0' from the algorithm given there?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by