How can I create a function from a model reference block that returns a value in Simulink coder?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Bryan
el 19 de Mzo. de 2014
Comentada: Bryan
el 20 de Mzo. de 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 comentarios
Respuesta aceptada
Kaustubha Govind
el 20 de Mzo. de 2014
You should be able to use Function Prototype Control to specify that your output be generated as a value and not a pointer.
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!