How to convert mexFunction to general c/c++ function

Hi everyone. I am converting mexFunction to general c/c++ function, so that it can be called in another c/c++ function. I think it's the problem dealing with arguments. How can i do it? Thanks in advance.

댓글 수: 4

Adam
Adam 2015년 12월 17일
It should just be a case of giving the function a proper name and stripping out the mxArray and other Matlab-specific stuff down to the C++ data structures into which you presumably copied the Matlab inputs. Then just pass those into your function instead of the mxArrays.
Would you more clarify? Assume i pass the 4-D singles matrix as an argument in matlab function. Then how can i imitate the passing this argument in c function.
You pass a pointer to the data. Then work with the data through that pointer in your "general" C/C++ code the same way you would in a mex function. What are you planning to do with this 4D array?
There are two arguments. One is image array, other is kernel. I am doing convolution with them. So, those are mutidimensional array. Would you put the code here for detail explanation?

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

답변 (1개)

Jan
Jan 2015년 12월 25일

0 개 추천

A clean Mex function uses the mexFunction() function to obtain the pointers to the values of the inputs at first. Then a subsection, or better sub-functions process the data. Finally the mexFunction() creates the outputs for Matlab.
Then it is relatively easy to remove the mexFunction() and use the sub-function for calculations from otehr C-code directly.
But maybe the mexFunction() creates the outputs at first and delivers pointers to allocated arrays to the subfunction. Or the mexFunction() mixes its job as a Matlab-C-gateway with calculations. Then a separation of the Mex and C parts is difficult.

댓글 수: 1

Thank you for your answer. Jan Would you glance at this link? mexfunction source How can i convert this mexfunction as a c sub function. Thanks in advance.

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

카테고리

도움말 센터File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

질문:

2015년 12월 17일

댓글:

2015년 12월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by