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

3 ビュー (過去 30 日間)
Farik John
Farik John 2015 年 12 月 17 日
コメント済み: Farik John 2015 年 12 月 26 日
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 件のコメント
James Tursa
James Tursa 2015 年 12 月 25 日
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?
Farik John
Farik John 2015 年 12 月 25 日
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 日
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 件のコメント
Farik John
Farik John 2015 年 12 月 26 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWrite 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