Filter löschen
Filter löschen

Random variation in a signal in Simulink

3 Ansichten (letzte 30 Tage)
davide
davide am 18 Feb. 2020
Kommentiert: davide am 22 Feb. 2020
I need to solve this problem in simulink.
I want to create a signal like the one in the picture, that at instant 4 sec change from 1 to 0 in 0.3 sec and then return to 1 from 5.7 sec to 6 sec. In this case the sequence starts at instant 4 sec.
The problem is that this sequence has to be introcuced in a simulink simulation at different time instants, that occurs randomnly. I tried to utilize some triggered blocks, but without success.
Has anyone a solutions?

Akzeptierte Antwort

Giuseppe Inghilterra
Giuseppe Inghilterra am 19 Feb. 2020
Hi,
if you can use stateflow in your simulink model, following chart could be a solution:
As you can see you start from state A where yout = 1. Then if a trigger input changes to true you pass to state A1 where yout starts to decrease by 0.01/0.3 at each simulation step. When yout reaches zero you pass to A2 state. Wait for 0.4 seconds and then you pass to state A4, where yout is incremented by 0.01/0.3 at each simulation step until it reaches one. Then you come back to state A.
This cycle is activated when trigger becomes true.
For example my trigger is generated by a sine wave function as shown below:
obtaining the following result:
Note that I run simulation with fixed step solver type and 0.01 as fixed step size.
  1 Kommentar
davide
davide am 22 Feb. 2020
I tested your solution and it works properly.
Thank you very much.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by