# Welch's method implementation

2 vues (au cours des 30 derniers jours)
Tu Nguyen le 3 Avr 2022
Réponse apportée : Tala le 3 Avr 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;
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);
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Tala le 3 Avr 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...
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Parametric Spectral Estimation dans Help Center et File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!