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

1 次查看(过去 30 天)
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!

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by