How can I create a function from a model reference block that returns a value in Simulink coder?

2 views (last 30 days)
I am using MATLAB 2013a with Simulink Coder ver 8.4 and am having some difficulty customizing the auto-generated code from my simulink model.
I have a top level model that performs some basic calculations and calls some model reference blocks for specific functions. Because my project will be used on a 32-bit embedded system, I have been using the ert.tlc target file as well as the "Generate reusable code" setting as modularity is a goal. I have noticed that for any model reference block Simulink Coder will produce C code such that the output of the model reference is stored in a pointer rather than the function returning a value and storing the value in, say, a local variable:
void myMdlRef(real32_T input, real32_T *output)
{
...
}
Where the function call in the top-level model appears as:
myMdlRef(input, &rtb_output);
I am wondering if there is a way to make the function return the value rather than storing the information in the pointer:
real32_T myMdlRef(real32_T input)
{
...
return output;
}
such that I can generate the top-level code as:
output = myMdlRef(input);
I have also seen the same code generation when performed on an atomic subsystem with the "Reusable code" function packaging set.
Any help would be greatly appreciated!

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 20 Mar 2014
You should be able to use Function Prototype Control to specify that your output be generated as a value and not a pointer.

More Answers (0)

Categories

Find more on Simulink Coder 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!