simulink模块中如何设置一个时变的参数变量 。
조회 수: 133 (최근 30일)
이전 댓글 표시
채택된 답변
dejom
2022년 11월 27일
我尝试给你做了一个能满足需求的小例子,你看下是不是你想要的。模型如Fig 1所示:其中:
增益模块中的参数为需要动态调节的函数。
自定义Matlab函数模块中的函数定义为为:
function y = userfun(t)
set_param('testing11/Gain','Gain',num2str(t));
y = t;
另外:需要在 菜单栏 File->Model Parameters->Model Parameters->Callbacks->InitFcn中设定初始的模块参数:
set_param('testing11/Gain','Gain','0'),我设定的初始参数为0。
运行结果如Fig 2所示:
注意:Constant模块中的 Sample time 不能是 inf
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Electromechanical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!