eml.extrinsic in Simulink MATLAB function blocks
7 views (last 30 days)
Show older comments
I have written an m-file that I would like to use in a Simulink MATLAB function block. I do not want to generate a compiled version but rather run it as an extrinsic function as suggested for rapid prototyping in “Tutorial: Integrating MATLAB Code with a Simulink Model for Filtering an Audio Signal” in the “Simulink/Using the Embedded MATLAB Function Block” documentation suggests. However, I have run into two issues. First, I do not have the example files. Second, when I use the command sequence in the MATLAB Function Block editor
Function output = MATLABFunctionBlockName(input); eml.extrinsic(‘m-file’); output = m-file(input);
I still get errors as if the code is going through the compiler. The code runs when called from within MATLAB. The errors are of the type encountered when converting from basic MATLAB to compile-able MATLAB. Any suggestions?
0 Comments
Answers (1)
Mike Hosea
on 31 Jan 2012
Are you pre-defining the outputs of each extrinsic call as you should? That is to say, your call sites should look something like:
y = zeros(size(x),class(x));
y = my_extrinsic_fun(x);
where the first definition of y is whatever the type and complexity of the the output of the extrinsic function should be. This is necessary because you must tell the compiler how to convert the data coming back from MATLAB to a native C type. I know that you say you're not wanting to generate a compiled version, but the technology always generates C code. It's just a question of whether that C code is linked to MATLAB or is standalone. -- Mike
0 Comments
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!