How can I create a function from a model reference block that returns a value in Simulink coder?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bryan
am 19 Mär. 2014
Kommentiert: Bryan
am 20 Mär. 2014
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!
0 Kommentare
Akzeptierte Antwort
Kaustubha Govind
am 20 Mär. 2014
You should be able to use Function Prototype Control to specify that your output be generated as a value and not a pointer.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulink Coder finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!