Can we generate c code for a matlab file which calls a mex source file

1 次查看(过去 30 天)
As we know that from matlab we can call c code using mex functions. If we have a matlab file in which I replace a matlab function with my mex source file and integrate it with the existing matlab file, can we generate the c code for this? I tried with emlc "mfile.m" but getting this error " Embedded MATLAB can only compile MATLAB files; unsupported file extension 'mexw32' for whatever mexfile we replaced.
If I am success to generate the c code for mfile, then most of my issues will be resolved. If possible pls send the answer to the follwoing mail id.

回答(1 个)

John Elliott
John Elliott 2011-5-21
The emlc command cannot compile mex functions. You have two options for integrating your mex function algorithm with the MATLAB file using emlc. 1) If you have the original C code for the mex function, then you can combine the original C code with the MATLAB code using emlc, and call the C code using the ceval function. Refer to the documentation for eml.ceval and custom code integration using emlc. With this approach, you can integrate your mex function algorithm with the compiled MATLAB file for both mex and standalone targets. 2) If you do not have the original C code for the mex function, you can use eml.extrinsic to declare that the mex function should be called using mexCallMATLAB. This will not 'compile' the mex function, but it will make it accessible from the code generated by emlc. Note that this only works if you are using emlc to generate a mex function; it will not work if you are generating standalone C code. Refer to the documentation for eml.extrinsic.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by