Setting initial condition of simulink integrator through code

Hi,
I am trying to cchange the initial condition of an integrator in Simulink by using Matlab code. I am using the following lines:
init_cond_integrator=[pi/3;0];
set_param('ClosedLoop_PID_MRFT_with_actuator/Manipulator Dynamics/Integrator1','InitialCondition',num2str(init_cond_integrator));
It gives the following error:
'ClosedLoop_PID_MRFT_with_actuator/Manipulator Dynamics/Integrator1' has unapplied changes. Please apply or cancel these changes before running the simulation.
Any help will be highly appreciated.
Thanks!

回答(1 个)

The error message says you have the dialog window open and changes have not been applied. Click apply or Ok and then proceed.

4 个评论

Thanks much, but still the problem was still there with another error of invalid setting.. Though I have solved it using external initial condition option in the integrator. I have connected constant blocks with the external port and I set those constants using set_param in the code.
Most likely, the value needs to be [1.0472; 0], not as shown 1.0472 0
Yes, right, but that seems undoable using the set_param command.
set_param(Block,'InitialCondition',mat2str([1,2]))

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品

版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by