How can I create a function from a model reference block that returns a value in Simulink coder?
조회 수: 2 (최근 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!
댓글 수: 0
채택된 답변
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!