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