필터 지우기
필터 지우기

how to add many function from different file in the same mex file

조회 수: 6 (최근 30일)
XAXRXTX
XAXRXTX 2014년 5월 25일
댓글: XAXRXTX 2014년 5월 26일
hi
I have two functions f1 and f2 in the same c file (functions.c) and their prototype in the same header file (functions.h), so how to use them without rewrite them in the main mex file code ????
thanks in advance

답변 (1개)

Jan
Jan 2014년 5월 25일
A mex file requires one mexFunction. This gateway function can call as many other functions from the same file as you want. Therefore it is not clear, why modifications of f1 or f2 could be needed.
  댓글 수: 1
XAXRXTX
XAXRXTX 2014년 5월 26일
first thanks for your response
so I will explain that problem again
1 - I have a header file named function.h contain the prototypes of 2 functions f1 and f2 for example:
double add(double a , double b);
double sub(double a , double b);
and I have in the other hand another file named function.c contain the declarartion of the privious function which are:
double add(double a,double b)
{
return a+b;
}
double sub(double a,double b)
{
return a-b;
}
so, the question is why the compiler return an error when I want to use the functions in the same manner as a c project.
but if I include both prototype and declaration of functions in the same header file , the program work perfectly

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by