Help understanding example for Inlining Matlab S-function

조회 수: 2 (최근 30일)
Nshine
Nshine 2019년 11월 6일
댓글: Nshine 2019년 11월 6일
In https://au.mathworks.com/help/rtw/tlc/introduction-inline-s-functions.html#f34125, I am trying to follow the example under the heading "Inline MATLAB File S-Functions"
Step 5 is unclear:
"Step 5 :On the Signal Attributes tab of the Inport Block Parameters dialog box, set the Port dimensions parameter to 5."
What do I need to click on to find this? Where do I find the "Inport Block Parameters dialog box"?
Thanks,

채택된 답변

galaxy
galaxy 2019년 11월 6일
You double click to Inport block, choose the Signal Attributes tab
6.PNG
  댓글 수: 3
galaxy
galaxy 2019년 11월 6일
I think step 5 for example about code generation from S-Function block.
So when you change contant block to inport block, generated code will same below.
/* S-Function (timestwo): '<Root>/MATLAB S-Function' */
/* Multiply input by two */
{
int_T i1;
const real_T *u0 = &times2_B.Gain[0];
real_T *y0 = &times2_Y.Out1[0];
for (i1=0; i1 < 5; i1++) {
y0[i1] = u0[i1] * 2.0;
}
}
5 dimenssion of inport is maximum of for loop
Nshine
Nshine 2019년 11월 6일
Thanks galaxy. That makes sense.
I'll note as well that there is no instruction in this example to compile the code by cliking on the Build icon (shortcut: Ctrl+B).
Once I build it, I can see a folder created named"
<simulink model name>_grt__rtw
In this folder is the file:
<simulink model name>.c
which has the lines in the previous comment within the "Model step function"
/* Model step function */
void times2_B_step(void)
{
/* S-Function (timestwo): '<Root>/S-Function' incorporates:
* Constant: '<Root>/Constant'
* Outport: '<Root>/Out1'
*/
/* Multiply input by two */
{
int_T i1;
const real_T *u0 = &times2_B_P.Constant_Value[0];
real_T *y0 = &times2_B_Y.Out1[0];
for (i1=0; i1 < 10; i1++) {
y0[i1] = u0[i1] * 2.0;
}
}
etc...
However, during there is an error during compilation:
Error(s) encountered while building "times2_B": ### Failed to generate all binary outputs.
If anyone else encounters this error, I found the same problem discussed here: https://au.mathworks.com/matlabcentral/answers/156208-how-do-i-fix-failed-to-generate-all-binary-outputs-error.
Having a path where the simulink model, .m and .tld files are stored without white spaces fixed the problem.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by