How do I change the parameters of a MATLAB Function Block during simulation?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a matlab function block (lets call it block.m) and it has 1 input and 2 parameters attached to it. The parameters to the block are loaded from the base workspace. I want to change the parameter values at each simulation. How do I do it?
댓글 수: 0
답변 (1개)
Pavan Sahith
2023년 10월 12일
Hi Aswin,
I understand you have a MATLAB Function block with 1 input and 2 parameters, and you want to change the parameter values at the start of each simulation.
If they are being fetched from the base workspace at start of each simulation, you can change their values using the ‘InitFcn’ callback in the Model Properties under the Model Settings which can be found under the MODELING tab in Simulink.
To ensure that your parameters are being loaded from the base workspace, you can utilize 'Model Explorer' to determine the workspace in which they are located and refer to the 'Symbols Pane' to confirm their type as 'Parameter Data' , by looking under the same MODELING tab.
If you want to change the value of parameters inside the MATLAB function, the variable in the base workspace do not get updated.
You can also refer to this similar MATLAB answers question for more understanding-https://in.mathworks.com/matlabcentral/answers/776747
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!