Why the length of power spectrum is fixed at 4096 when the signal's length varies ?

8 ビュー (過去 30 日間)
I was using pspectrum function to obtain the power spectrum of time series signals. However, I find that when I set different length of time series signal, the power spectrum return by the pspectrum function has fixed length 4096. I want to konw what underlying mechanism is causing this result ?
diffSignalLengths = 50:50:5000; % different signal length for experiment
Fs = 3e3; % sampling frequency
lenPS = zeros(numel(diffSignalLengths),1);
for ii = 1:numel(diffSignalLengths)
x = rand(diffSignalLengths(ii),1);
P = pspectrum(x,Fs);
lenPS(ii) = length(P);
end
disp(all(lenPS == 4096))
1

採用された回答

Mathieu NOE
Mathieu NOE 2025 年 6 月 12 日
移動済み: Walter Roberson 2025 年 6 月 13 日
hello
in "auto" mode (i.e when you don't specify the frequency resoltion) , the fft is done with 4096
this is visible in the pspectrum code :
if isempty(opts.FrequencyResolution)
% Auto mode
Npoints = uint32(4096);
else
% Set Npoints to achieve desired resolution
fspan = 4*Fs;
Npoints = uint32((1+fspan/opts.FrequencyResolution(1)));
end
  2 件のコメント
Chuguang Pan
Chuguang Pan 2025 年 6 月 12 日
移動済み: Walter Roberson 2025 年 6 月 13 日
@Mathieu NOE. Thanks for your answer.
Mathieu NOE
Mathieu NOE 2025 年 6 月 12 日
移動済み: Walter Roberson 2025 年 6 月 13 日
my pleasure !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by