0
votes

I have simple Simulink model and I would like to change the initial condition of integrator based on some signal. This signal can take values 1 or 0 and initial conditions of integrator should be equal to 1.16 or 0.65 respectively.

I tried to set a parameter x_init in Model Workspace (and then use it in Integrator block), but I couldn't access it via function. Then I tried to run MATLAB function inside simulink model with set_param(...), but I got error:

Function 'set_param' is not supported for code generation. Consider adding coder.extrinsic('set_param') at the top of the function to bypass code generation.

This is how the structure of model looks like in Model Explorer. I would like to change the x initial condition. Model Explorer view

1

1 Answers

1
votes

Using a workspace variable as you are doing is the wrong approach.

Change the Initial Condition Source property of the integrator to external. This will give the block an additional in port. The value of the signal fed into this port when the integrator is reset is taken as the initial condition.