Initial output value of Outport in top level subsystem of a model.

3 次查看(过去 30 天)
Consider an unconditional top level subsystem of a model. 'Initial output' field of Outports in top level is disabled in block parameter dialog. Does this field affect the code generation. If yes how it will affect?
I am using matlab r2007a with embedded coder. I have seen if Initial output has some value and even if it is disabled, associated signal in generated code is initialized with that value in mdl_initialize function.

回答(1 个)

Desiree
Desiree 2011-9-8
There is an optimization option which you can check to remove the zero initialization of root level I/O ports: "Remove root level I/O zero initialization". See the doc here. Be aware that this only counts for initial values of zeros or when the option is disabled.
  2 个评论
TAB
TAB 2011-9-8
Thanks for answer. Actually my question is different-
1. I have kept a trigger port at root level for unit testing. So root level is conditional. I initialize a outport (named HightSettings) with Initial output =100.
2. Now for code generation i removed the trigger port. So root level is now unconditional. Hence Initial output in port 'HightSettings' is disabled(Greyed but still showing 100 in textbox).
In the generated code HightSettings is initialized in model_initialize() function as
Set_HightSettings(100U);
How a disabled field can affect the code geneartion. How embedded coder handles the Initial output of outports.
Desiree
Desiree 2011-9-8
This does sound like a bug. There shouldn't be an initialization when the option is disabled. I wasn't able to reproduce this in newer versions though. Please try with a newer version than R2007a to see if the issue persists.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by