- ‘Configure Model from Command Line’ : https://www.mathworks.com/help/releases/R2022b/rtw/ug/configure-model-from-command-line.html
- ‘set_param’ function: https://www.mathworks.com/help/releases/R2022b/simulink/slref/set_param.html
- ‘getActiveConfigSet’ function: https://www.mathworks.com/help/releases/R2022b/simulink/slref/getactiveconfigset.html
Simulink Initial Conditions - Active/Deactive Input and Initial State from MATLAB Script
조회 수: 6 (최근 30일)
이전 댓글 표시
Dear Community,
I was surfing over the web, but i could not find resources that can help me with the following. Also, I am using MATLAB 2022b and launching Simulink simulations from MATLAB using the command:
SimData = sim('Simulinuk_Model.slx','simulationmode','Normal');
However, i want to active and deactive the following options (Input and Initial state check and uncheck) through a matlab script:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1777690/image.png)
Could someone please be so kind to provide me the example code?
Thank you very much in advance
댓글 수: 0
채택된 답변
Sandeep Mishra
2024년 9월 23일
Hi Rodrigo,
To enable or disable parameters in a Simulink model, you can effectively use the 'set_param' function in MATLAB. This function requires the current configuration set of the Simulink model, along with the specific parameter name and the desired value.
You can refer to the following code snippet to check (‘on’) and uncheck (‘off’) the model parameters:
load_system("simulink_model.slx")
% Fetching current configuration set
cs = getActiveConfigSet('simulink_model');
% To uncheck "Load from workspace" for input data
set_param(cs, 'LoadExternalInput', 'off');
% To uncheck "Load from workspace" for input state
set_param(cs, 'LoadInitialState', 'off');
% Save changes and close the model
save_system('simulink_model');
close_system('simulink_model');
For more information, refer to the following MathWorks documentation:
I hope this helps you in updating the model parameters.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!