Detect spikes and mark times
Afficher commentaires plus anciens
Hi.

I am trying to detect a spike in simulink for a signal (by spike I mean when the signal exceeds a certain value with a defined height). Futhermore, because I want to do an integration of this spike I need to have the two time values. Does anybody know how this can be achieved in matlab?
Thank you very much, Angel
Réponses (1)
Sebastian Castro
le 5 Juin 2014
0 votes
You can pick out the values of these spikes using a Triggered Subsystem.
What I've done in the screenshot below is:
- Use a Compare to Constant block to create a logical signal. This tells me whether or not the signal is above the spike
- Use a Triggered Subsystem that, when triggered, picks the current simulation time. This time is supplied with a Clock block.
- To pick out t1, you can configure your Triggered Subsystem to find the RISING EDGE (i.e. when the logical signal goes from 0 to 1).
- To pick out t2, you can configure another Triggered Subsystem to find the FALLING EDGE (i.e. when the logical signal goes from 1 to 0).
If you have multiple peaks in your signal, your algorithm may have to be a little "smarter" than this. However, this should give a good start for how you can use Triggered Subsystems to capture "snapshots" in your model.

1 commentaire
Image Analyst
le 7 Juin 2014
Angelos's "Answer" moved here since it's really a reply to Sebastian, not an answer to the original question:
Thank you very much.
Angelos, you can "thank" him also by accepting his answer and voting for it.
Catégories
En savoir plus sur Electrophysiology dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!