How do I find the peak of a signal and the time of peak?

3 views (last 30 days)
I am trying to implement a model in simulink in which I need to identify the magnitude and time of the occurance of the peak (max magnitude) for a time varying discrete signal. I can not use a buffer because it does not have HDL support. I tried using MinMax Running Resettable block but that only gives the magnitude and not the time. Any idea how can I do this?
Thanks in advance!

Accepted Answer

Timo Dietz
Timo Dietz on 21 Sep 2022
Edited: Timo Dietz on 21 Sep 2022
Hello,
if you are already able to catch the 'max', just attach a 'Detect Change' block to it and apply this output to a triggered subsystem. (The subsystem contains just a connection from input to output.)
The input of the subsystem should now be connected to a 'Clock' block. Thus, the output delievers the current clock value, each time a new max has been detected.
Btw, for the max detection you can just use a 2-input max block. One input connected to the signal and the second to the max blocks output via a unit delay block - as feedback.
Does this solve your issue?
  4 Comments
Timo Dietz
Timo Dietz on 21 Sep 2022
It's even more easy:
Just use a 'greater than' one input connected to the signal, the other to the unit delay output.
The output of this block is the trigger for the subsystem.
Now add a second in/out path to the triggered subsystem, one input connected to your signal, the other to the Clock.
Finally connect the output of the subsystem which delivers the signal max to the input of the unit delay.
Thus, you need no 'detect change' and no 'max' block. :-)
Please accept one or the other answer to close this question - provided that your issue is solved :-)
Timo Dietz
Timo Dietz on 21 Sep 2022
Edited: Timo Dietz on 21 Sep 2022
Concerning the three last peaks:
Provided that a got your point, you can just attach unit delay blocks to your current max value and stored Clock (both outputs of the triggered subsystem block in the second solution I described).
Attach the outputs of the delay blocks to the inputs of a second triggered subsystem (copy of the first).
Again, these outputs to the inputs of a third subsystem.
The trigger inputs for the subsystems are all the same.
The subysystems outputs should deliver the last three value/time pairs.

Sign in to comment.

More Answers (1)

Kiran Kintali
Kiran Kintali on 25 Sep 2022

Community Treasure Hunt

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

Start Hunting!