simulink模块中如何设置一个时变的参数变量 。
118 次查看(过去 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!