How can I isolate a segment of ECG data in MATLAB?

Click For Summary
SUMMARY

The discussion focuses on isolating a segment of ECG data in MATLAB, specifically plotting heartbeats from a raw dataset. The user successfully imports ECG data and plots it in the time domain but struggles to isolate a specific time segment from 50 to 60 seconds. A solution is provided using the MATLAB function find to create an index for the desired time range, allowing for accurate plotting of the specified segment.

PREREQUISITES
  • Basic understanding of MATLAB programming
  • Familiarity with time-domain signal representation
  • Knowledge of ECG data structure
  • Experience with MATLAB plotting functions
NEXT STEPS
  • Learn how to use MATLAB's find function for indexing data
  • Explore MATLAB's plotting capabilities for time-series data
  • Study signal processing concepts related to ECG analysis
  • Research self-study resources for signals and systems
USEFUL FOR

This discussion is beneficial for MATLAB users, biomedical engineers, and students studying signal processing, particularly those working with ECG data analysis and visualization.

TomUIC
Messages
5
Reaction score
0
I have inputed the following, I was given a signal and told to plot it in a time domain. The signal ECG is a data file and imported.

N = 15000;
fs = 250;
t = linspace(0, 60, N);
%signal = ecg data = ecg

subplot (2,1,1);
plot (t,ecg);
title ('Time-Domain ECG')
xlabel ('Time (s)')
ylabel ('Magnitude')

The above works just fine, but I wish to focus on a part of the data.

The problem is I do not know how to isolate a segment of the data, I'm not very experienced in MATLAB. The data represents heartbeats, and my goal is to plot one from the raw data, say for instance from time 50-60.

I had thought perhaps the following would work:

plot (t(50:60),ecg(my start point:end);

Obviously it does not, so I'm asking for some help.
 
Physics news on Phys.org
Try this Tom
Code:
idx = find(t>50 & t<60);
plot(t(idx),ecg(idx))
 
Thank you very much, you have ended a great deal of frustration for what amounted to a simple problem. I hate knowing what you want to do but not knowing the correct terminology to search for the help. I doubt this class will teach me much about signals and systems in the end, but I think I'll be better at MATLAB for my trouble.

Any suggestions on where to actually learn signals and systems would be appreciated, in terms of self-study.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K