Can't understand why Pwelch claims window is larger than input signal

5 ビュー (過去 30 日間)
Jude
Jude 2024 年 9 月 27 日
回答済み: Jude 2024 年 9 月 29 日
segment_length = 1229;
hannw = hann(segment_length);
overlap_length = round(segment_length / 2);
disp(size(SuperTrialH2Hit))
returns 30 207701
[pxx4HH, hz4HH] = pwelch(SuperTrialH2Hit, hannw, overlap_length, nextpower2(numel(SuperTrialH2Hit)), SR);
returns
Error using signal.internal.spectral.welchparse>segment_info (line 345)
The length of the segments cannot be greater than the length of the input signal.
Error in signal.internal.spectral.welchparse (line 34)
[L,noverlap,win] = segment_info(M,winp,noverlap1);
Error in welch (line 56)
signal.internal.spectral.welchparse(x,esttype,args{:});
Error in pwelch (line 174)
[welchOut{1:nargout}] = welch(x,funcName,inputArgs{:});

採用された回答

William Rose
William Rose 2024 年 9 月 27 日
編集済み: William Rose 2024 年 9 月 27 日
[Edit: correct spelling in my comments.)
You need to use the transpose of the data array. pwelch() finds the spectrum of each column, when the input data is an array. And in your array, the data whose spectra you wish to compute are in rows. See the following, which runs without error.
SuperTrialH2Hit=rand(30,207701);
SR=1; % sampling rate
segment_length = 1229;
hannw = hann(segment_length);
overlap_length = round(segment_length / 2);
disp(size(SuperTrialH2Hit))
30 207701
[pxx4HH, hz4HH] = pwelch(SuperTrialH2Hit', hannw, overlap_length, ...
nextpow2(numel(SuperTrialH2Hit)), SR);
Good luck.
  1 件のコメント
William Rose
William Rose 2024 年 9 月 27 日
@Jude, I'm surprised your code ran, because it uses nextpower2(), which is not a built-in function. I changed it to nextpow2() for my example above.

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

その他の回答 (1 件)

Jude
Jude 2024 年 9 月 29 日
Hiya!
Simple, thank you for taking the time. I actually made my own nextpower2 function as I didn't realise there was one built in!!!!
Jude

カテゴリ

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

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by