Use Peak Finder to Find Heart Rate from ECG Input
This example shows how to use the Time Scope Peak Finder panel to measure the heart rate from an ECG.
To emulate a heart beat, the model Preload creates the variable mhb
in the MATLAB® workspace. This variable is then called by the Signal From Workspace block. To see all the model Preload commands, open the Model Explorer and look at the Callback functions.
Run your model to see the time domain output.
To show the Peaks section, click the Measurements tab in the Time Scope toolstrip, and select Peak Finder.
Click the Peak Finder dropdown arrow, and enter 10 for Num Peaks. The Time Scope Peaks section now displays a list of 10 peak amplitude values, and the times at which they occur.
Turn on the Cursor Measurements by selecting Data Cursors.
Click the Data Cursors dropdown, and set the cursor time values to two consecutive peak times, for example 1.725s and 2.4s. The time difference between all peaks is 675 milliseconds.
Therefore, you can calculate the heart rate of the ECG signal: