How to vary Gain in Simulink dependent on input's amplitude and phase during runtime ?

6 次查看(过去 30 天)
The Gain block and continuous block in Simulink require the user to specify a gain. This can be a workspace variable. But I want to vary this gain during runtime. I can't seem to get a solution for this. This idea is simple but I can't believe it is so difficult to implement.
I have tried using another block to write to workspace, but found out that the 'to workspace' block only writes to the workspace after the simulation ends or pauses.
I can store the variable in a data memory block, but I don't know how to specify the gain value(s) for the gain/PID block in this case.
  2 个评论
Harsh Kumar
Harsh Kumar 2021-7-29
Let's suppose my gain is 'fun' which depends upon the amplitude(x)of the input signal.
fun = @(x) (cos(x)).^2/(1+2*cos(x)).^3;
And also I've stored the amplitude in a data storage in workspace.
How can I implement this in a Gain block in simulink?

请先登录,再进行评论。

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2021-7-29
Use the Product block. The Gain block is an operation of multiplication, right?

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by