How to generate code for mex files too while generating hardware specific code from simulink ?

1 vue (au cours des 30 derniers jours)
My simulink model contains a MATLAB function block which calls a precompiled mex file. I want to generate the code from this model for a specific hardware. But when I compile the generated C code, the line calling the mex file gives an error. I want to be able to generate c code without the error. Is there a way to do this?
Thanks.

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 12 Fév 2014
Since MEX-files are specific to the MATLAB environment, you cannot run them on an embedded target. If you have the equivalent standalone C code equivalent also, you can use the following code style to call the MEX-file during simulation, and the C-code in the generated code:
function y = myfcn(u)
coder.extrinsic('mymex');
y = 0; %pre-allocate
if coder.target('Sfun')
y = mymex(u);
else
y = coder.ceval('foo', u);
end
Please refer to the documentation for more information on coder.target and coder.ceval.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by