Filter löschen
Filter löschen

Welch's method implementation

2 Ansichten (letzte 30 Tage)
Tu Nguyen
Tu Nguyen am 3 Apr. 2022
Beantwortet: Tala am 3 Apr. 2022
Hi Dears;
I want to loop through the data 256 points at a time, and 128 points overlap, However, I beleive that my function missing something to perform that because when I run the code, it returns "Unable to perform assignment because the size of the left side is 512-by-1 and the size of the
right side is 256-by-128."
How can I do loop through the data 256 points at a time and 128 points overlap?
I really appreciate for your help
clc;
close all;
clear;
load('ecg_60Hz_Noise_Fs200Hz.mat');
data = ecgn(1:1024)';
Fs = 200;
w = hamming(256);
psd = zeros(512,7);
for i = 0:6
temp = data(1+256*i:128+i*256)'.*w;
temp = fft(temp);
temp = abs(temp).^2;
psd(:,i+1) = temp;
end
psd1 = mean(psd,2);
psd1 = psd(1:257);
psd1 = psd1/(Fs*sum(w.^2));
psd1(2:end-1)= psd1(2:end-1)*2;
figure
plot(f,psd1);

Akzeptierte Antwort

Tala
Tala am 3 Apr. 2022
Instead of the for loop, I would reshape the array first.
temp0 = reshape(ecgn,[256,4]);
temp1=fft(temp0);
temp2=abs(temp1).^2;
psd=temp2;
then the rest of your calculations...

Weitere Antworten (0)

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by