Welch's method implementation

9 ビュー (過去 30 日間)
Tu Nguyen
Tu Nguyen 2022 年 4 月 3 日
回答済み: Tala 2022 年 4 月 3 日
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);

採用された回答

Tala
Tala 2022 年 4 月 3 日
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 件)

カテゴリ

Help Center および File ExchangeParametric Spectral Estimation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by