How can I limit in time a sine wave in Simulink
6 views (last 30 days)
Show older comments
Hello everyone !
I have to face a problem and I cannot find a solution. Could you help me ? Actually, in simulink, I would like to use a sine wave but just during a precise time. Let's say I want to do a simulation during 100s and I would like to use the sine wave just during 10s and then stop. How can I do that ? How can I control in time my sine wave ?
Thank you very much for your help !
- Mike
1 Comment
Answers (1)
Gojo
on 31 Aug 2024
Edited: Gojo
on 31 Aug 2024
Hey Mike,
I understand that you want to use sine waves only for some specified time steps. I believe you could achieve this functionality by using a Switch Block. You can pass a control signal which would have a True value when you would want to use the sine wave and else it would have a False value. You can generate this signal as an array in your MATLAB workspace if you know ahead in time at which time steps you would require to use the sine wave. Otherwise you could generate this control signal by using a Clock Block and your logic in Simulink itself.
Once you have the above mentioned control signal, you can use the Switch Block to output the Sine wave when the control signal has a True value, otherwise you may output a constant signal from the block. You can create your own subsystem as below:

I hope this helps!
1 Comment
Gojo
on 31 Aug 2024
Enabled Subsystems could also be helpful in this scenario: https://www.mathworks.com/help/simulink/ug/enabled-subsystems.html
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!