about PSD with trapz or other integral function

8 Ansichten (letzte 30 Tage)
seokin baek
seokin baek am 26 Mär. 2019
I want to know that how to calculate LF/HF. I used trapz function. but it was not working.
i want to know how to integral PSD graph with 0.04~0.15 Hz and 0.15~0.4Hz. (Hz is x axis.)
clc
clear all
close all
%% ECG Signal
data = load('max30001-8.csv');
x = data(1:end, 1); % Time
y = data( 1:end, 2); % ECG signal
t2 = x';
ecgsig = y';
Fs = 125;
% ecgsig : 1x(O) double, 1로 정규화된 ECG 신호
% t2 : 1x(O) double, [sec], 0.001초 단위
% Fs 데이터 샘플 레이트 : 단위 시간당 샘플 개수, 시간 단위가 초이면 샘플 레이트의 단위는 헤르츠, 0.008s, 125Hz
%% Find the ECG peaks
[pks,locs] = findpeaks(ecgsig,'MinPeakProminence',0.3,'MinPeakHeight',2000);
% 피크가 나타나는 지점의 인덱스 반환
for i = 1 : length(locs)
locs(i) = t2(locs(i));
end
%% Determine the RR intervals
RLocsInterval = diff(locs);
%% Derive the HRV signal
tHRV = locs(2:end);
HRV = 1./RLocsInterval;
Hz = HRV(1:end);
power = (tHRV).^2.*0.001/Hz;
m=abs(power);
%% Plot the signals
figure
a1 = subplot(2,1,1);
plot(t2,ecgsig,'b',locs,pks,'*r')
grid
a2 = subplot(2,1,2);
plot(tHRV,HRV)
grid
xlabel(a2,'Time(s)')
ylabel(a1,'ECG (mV)')
ylabel(a2,'HRV (Hz)')
figure
% Use plomb to calculate the spectrum of the HRV signal.
[power,Hz] = plomb(HRV,power,'Pd',[]);
plot(Hz,power)
grid
xlabel('Frequency[Hz]')
ylabel('PSD[sec^2/Hz]')
Hz=(0.15:0.4);
HF=trapz(Hz,power);
Hz=(0.04:0.15);
LF=trapz(Hz,power);
Str=LF./HF;
fprintf('%f',Str);

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by