Code Generation for Delay block generates continuous if statement for loading initial value
Hello, I have the following model:
it is a delay block with that should use the input at the first time step as the value.
In the generated code I see that in the initialize function it is setting "untitled_DW.icLoad = true" such that it loads the value on the first execution. However this generates an if statement that only needs to be checked at the 1st iteration, is it possible to have this load statement in the initialize function such that it is removed from the step the function?
/* Model step function */
void untitled_step(void)
{
/* Delay: ‘<Root>/Delay’ incorporates:
* Inport: ‘<Root>/Input’
*/
if (untitled_DW.icLoad) {
untitled_DW.Delay_DSTATE = untitled_U.Input;
}
/* Outport: ‘<Root>/Out’ incorporates:
* Delay: ‘<Root>/Delay’
*/
untitled_Y.Out = untitled_DW.Delay_DSTATE;
/* Update for Delay: ‘<Root>/Delay’ incorporates:
* Inport: ‘<Root>/Input’
*/
untitled_DW.icLoad = false;
untitled_DW.Delay_DSTATE = untitled_U.Input;
}
/* Model initialize function */
void untitled_initialize(void)
{
/* InitializeConditions for Delay: ‘<Root>/Delay’ */
untitled_DW.icLoad = true;
}Hello, I have the following model:
it is a delay block with that should use the input at the first time step as the value.
In the generated code I see that in the initialize function it is setting "untitled_DW.icLoad = true" such that it loads the value on the first execution. However this generates an if statement that only needs to be checked at the 1st iteration, is it possible to have this load statement in the initialize function such that it is removed from the step the function?
/* Model step function */
void untitled_step(void)
{
/* Delay: ‘<Root>/Delay’ incorporates:
* Inport: ‘<Root>/Input’
*/
if (untitled_DW.icLoad) {
untitled_DW.Delay_DSTATE = untitled_U.Input;
}
/* Outport: ‘<Root>/Out’ incorporates:
* Delay: ‘<Root>/Delay’
*/
untitled_Y.Out = untitled_DW.Delay_DSTATE;
/* Update for Delay: ‘<Root>/Delay’ incorporates:
* Inport: ‘<Root>/Input’
*/
untitled_DW.icLoad = false;
untitled_DW.Delay_DSTATE = untitled_U.Input;
}
/* Model initialize function */
void untitled_initialize(void)
{
/* InitializeConditions for Delay: ‘<Root>/Delay’ */
untitled_DW.icLoad = true;
} Hello, I have the following model:
it is a delay block with that should use the input at the first time step as the value.
In the generated code I see that in the initialize function it is setting "untitled_DW.icLoad = true" such that it loads the value on the first execution. However this generates an if statement that only needs to be checked at the 1st iteration, is it possible to have this load statement in the initialize function such that it is removed from the step the function?
/* Model step function */
void untitled_step(void)
{
/* Delay: ‘<Root>/Delay’ incorporates:
* Inport: ‘<Root>/Input’
*/
if (untitled_DW.icLoad) {
untitled_DW.Delay_DSTATE = untitled_U.Input;
}
/* Outport: ‘<Root>/Out’ incorporates:
* Delay: ‘<Root>/Delay’
*/
untitled_Y.Out = untitled_DW.Delay_DSTATE;
/* Update for Delay: ‘<Root>/Delay’ incorporates:
* Inport: ‘<Root>/Input’
*/
untitled_DW.icLoad = false;
untitled_DW.Delay_DSTATE = untitled_U.Input;
}
/* Model initialize function */
void untitled_initialize(void)
{
/* InitializeConditions for Delay: ‘<Root>/Delay’ */
untitled_DW.icLoad = true;
} embedded coder, delay block MATLAB Answers — New Questions