Hi all,
I'm working on a function that returns a plot based on the heart rate of the user. Example: if the user's heart rate is 60 BPM, the plot will display 10 beats in 10 seconds or 20 beats in 10 seconds if it's 120BPM. I have an ecg.m function I downloaded from here that I'm using to create and replicate an ECG pattern. I'm having problems getting the plot to display in seconds rather than samples. I'm also hoping to do a live ECG view using dsp.timescope. If one or both of these could be solved that would great!
Best, Chris

댓글 수: 4

Christopher Houk
Christopher Houk 2017년 10월 27일
편집: Christopher Houk 2017년 10월 27일
Here is my code
function [] = plotFile(heartRate,titleName,beats,dt)
%%Function plotFile
%This function is to be used with FILENAME and will display inputs
%vs. the outputs in the first figure. In the second figure, an ECG of the
%first instance of the input file will be displayed.
titleName = 'Data';
heartRate = [60;69;55;50;42];
beats = [100;80;60;10;12];
dt = [00;70;65;12;17];
%%Plot inputs vs. outputs
figure(1)
hold on
plot(dt,heartRate,'r*','MarkerFaceColor','r')
plot(beats,heartRate,'b*','MarkerFaceColor','b')
xlabel('Time (s)')
ylabel('Beats')
legend('Time vs. Heart rate','Beats vs. Heart rate')
ylim([0 inf])
xlim([0 inf])
title(titleName)
hold off
%%Plot ECG Signal
heartRate = heartRate(1,1);
Fs = heartRate/60;
x = ecg(2700);
y = repmat(x,[1 30]);
sigData = y(1:16000)';
t = linspace(0, 15999, 16000)/Fs;
figure(2)
plot(t,sigData)
ylabel('Voltage (mV)')
xlabel('Seconds')
legend('ECG Signal')
axis ([0 16000 -2 2])
title(titleName)
end
%%Attempt at scope
% TS_ECG = dsp.TimeScope('SampleRate', Fs,...
% 'TimeSpanSource', 'Auto',...
% 'ShowGrid', true,...
% 'TimeUnits','Seconds',...
% 'Title',titleName);
% TS_ECG(sigData);
% TS_ECG.YLimits = [-2, 2];
Maitreyee Mordekar
Maitreyee Mordekar 2017년 11월 2일
Hi Christopher,
Could you please share the ecg.m file? That will help us understand the issue better.
Regards, Maitreyee
Christoph F.
Christoph F. 2017년 11월 2일
편집: Christoph F. 2017년 11월 2일
ecg() is a MatLAB function. I think it is part of the signal processing toolbox.
Maitreyee Mordekar
Maitreyee Mordekar 2017년 11월 6일
Hi Christoph F.,
I meant to ask if he is referring to a MATLAB shipping example or the following file exchange submission:
Anyways, thanks for answering his query :)
Cheers, Maitreyee

댓글을 달려면 로그인하십시오.

답변 (1개)

Christoph F.
Christoph F. 2017년 11월 2일
편집: Christoph F. 2017년 11월 2일

0 개 추천

> I'm having problems getting the plot to display in seconds rather than samples.
It looks like your t vector is in samples instead of seconds.
Fs = heartRate/60;
x = ecg(2700);
...
t = linspace(0, 15999, 16000)/Fs;
The actual sampling rate is 2700*Fs, not Fs. Try
t = linspace(0, 15999, 16000)/(2700*Fs);
Side question: How is the "heart rate" of the user determined for this function? Is it a given value used for generating ECG test signals?

질문:

2017년 10월 27일

댓글:

2017년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by