Hello, everyone.
I need to create a script where overlapping is parameterized. I did it this way:
N = length(u); % = length(y)
percentage = 0.5; %range = [0.01 - 0.99]
window = hanning(round(N/4.5));
overlap = round(length(window)*percentage);
[SuyW,fw] = cpsd(u,y,window,overlap,[],fs);
Can anyone tell me if this is correct?

 採用された回答

William Rose
William Rose 2022 年 8 月 22 日
編集済み: William Rose 2022 年 8 月 22 日

1 投票

[edit: correcting my recommendation from overlap=floor(...) to overlap=ceil(...)]
Yes this is reasonable.
You can answer your quesiton by trying some different values for N and observing the resulting values for window length and overlap:
%N = length(u); % = length(y)
N=[500,1000,2000,4000];
percentage = 0.5; %range = [0.01 - 0.99]
for i=1:4
window = hanning(round(N(i)/4.5));
overlap = round(length(window)*percentage);
fprintf('N=%d, winLen=%d, overlap=%d\n',N(i),length(window),overlap);
end
N=500, winLen=111, overlap=56 N=1000, winLen=222, overlap=111 N=2000, winLen=444, overlap=222 N=4000, winLen=889, overlap=445
The results look reasonable.
You chose a window length that is 1/4.5 times the signal length, in all cases. This choice will usually allow for 8 half-overlapped windows in the signal. It is possible that, due to rounding, the 8th and final window will not fit. For example, N=98, N=502, N=512, N=1006, N=1024, and others. Therefore I would use
window = hanning(floor(N/4.5));
overlap = ceil(length(window)*percentage);
to assure that the window goes onto the signal 8 times.

2 件のコメント

Amanda Santos
Amanda Santos 2022 年 8 月 22 日
Thank you!
William Rose
William Rose 2022 年 8 月 23 日
You're welcome, @Amanda Santos. If my answer suffices, please accept it. Good luck with your work.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by