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 Peak Finder panel, in the Time Scope menu, select Tools > Measurements > Peak Finder.
Expand the Settings section, enter 10 for Max Num of 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 Tools > Measurements > Cursor Measurements.
Set the cursor time values to two consecutive peak times, for example 1.725 and 2.4. The time difference between all peaks is 675 milliseconds.
Therefore, you can calculate the heart rate of the ECG signal: