MATLAB Answers

Where are the Block Parameters I entered? Why do they get different values in the generated code?

1 view (last 30 days)
sarah haras
sarah haras on 15 Mar 2016
Commented: sarah haras on 21 Mar 2016
Hi there,
I generated Code with Simulink Coder from my model. Teh model contains some gains. As gain value i entered variables, such as r or Alpha. The values are defined in an mat-File: r =22, Alpha =9. But in my generated Code i have some issues with These block parameters. They are deklared in Model_data.c in the struct shown at the end. So as you can see, with r is everything fine, but Alpha=9 became Alpha = 1207959552. Someone can explain this to me?
Thx a lot!
P_Model_T Model_P={
22, /*Variable: r
*Referenced by: '<sr3>/r_Constant'
1207959552 /*Variable: Alpha
*Referenced by: '<sr3>/Alpha_Constant'


Sign in to comment.

Accepted Answer

Mark McBroom
Mark McBroom on 19 Mar 2016
it looks like simulink coder selected a fixed point data type for the constant. fix this by double clicking on the gain block and explicitly specifying the desired data type.

  1 Comment

sarah haras
sarah haras on 21 Mar 2016
thanks for your answer, on the gain-block itself i had specified the value as an int. But that gave me the hint to specify the data type in the m-file, too. I did this via Simulink.Parameters. With this the Parameters appear clear now.

Sign in to comment.

More Answers (0)

Sign in to answer this question.