辅导matlab留学生程序、辅导matlab金融统计
- 首页 >> Matlab编程clear all
close all
load necg
%% load data
ecg=s103_c;
%parameter
%例子中采样率360Hz,我们用的是100Hz
fs=360;
%time vector
len=length(ecg);
t=1/fs:1/fs:len/fs;
%%
plot(t,ecg)
xlabel('time/s')
ylabel('ECG')
%pick 3~5s of the data and do self-correlation
%in this case we choose 3s, which is 1080 samples
sl=3*fs;
t=t(1:sl);
ecg=ecg(1:sl);
for i=1:sl/2
sc(i)=ecg(1:sl/2)*ecg(i:sl/2+i-1)';
end
figure
plot(t(1:sl/2),sc)
xlabel('time/s')
ylabel('sc')
%the peak of the sc exists at 0.86s
%which means the average heart rate during(1s~3s)is 1/0.86s (~70b/min)
%寻找最大值可以在一定范围内寻找,具体范围根据生活中正常心率范围定