blackman and flattopwin cannot be used with pwelch
Francesco Potorti`
Potorti at isti.cnr.it
Tue Feb 5 07:19:31 CST 2008
>>>> pwelch.m as distributed in the signal package of octave-forge does not
>>>> accept a window with negative values. However, blackman(4096) and
>>>> flattopwin(4096) generate negative values.
>>>>
>>>> I suspect that as far as blackman is concerned, it is just a rounding
>>>> error, but flattopwin definitely generates negative values.
>>>>
>>> Could you propose a fix?
Here it is. By the way, I corrected a couple of places where the name
of the window (Hann, Hamming) was used where the name of the function
(hanning, hamming) should have.
--- pwelch.m.orig 2008-01-18 13:38:54.000000000 +0100
+++ pwelch.m 2008-02-05 14:13:04.000000000 +0100
@@ -62,7 +62,7 @@
%% y %% [non-empty vector] system-output time-series data
%%
-%% window %% [real vector] of window-function values between 0 and 1; the
+%% window %% [real vector] of window-function real values; the
%% %% data segment has the same length as the window.
-%% %% Default window shape is Hamming.
+%% %% Default window shape is hamming.
%% %% [integer scalar] length of each data segment. The default
%% %% value is window=sqrt(length(x)) rounded up to the
@@ -187,5 +187,5 @@
%% 20dB/decade. You can inspect the FFT of a Hann window by plotting
%% "abs(fft(postpad(hanning(256),4096,0)))".
-%% The default window is Hamming.
+%% The default window is hamming.
%% 4) ZERO PADDING:
%% Zero-padding reduces the frequency step in the
@@ -229,5 +229,5 @@
%% %% units of overlap are "number of samples"
%% %% defaults: Nfft=min(length(x),256), Fs=2*pi, length(window)=Nfft,
-%% %% window=Hanning, do not detrend,
+%% %% window=hanning, do not detrend,
%% %% N.B. "Sloppy" is not available.
%%
@@ -236,5 +236,5 @@
%% [Pxx,f]=pwelch(x,window,overlap,nfft,Fs,...);
%% %% units of overlap are "number of samples"
-%% %% defaults: length(window)==length(x)/8, window=Hamming,
+%% %% defaults: length(window)==length(x)/8, window=hamming,
%% %% Nfft=max(256,NextPow2), Fs=2*pi, do not detrend
%% %% NextPow2 is the next power of 2 greater than or equal to the
@@ -487,6 +487,6 @@ else
elseif ( is_win==1 && ( ~isreal(arg) || fix(arg)~=arg || arg<=3 ) )
error( 'pwelch: arg %d (window) must be integer >3', iarg+1 );
- elseif ( is_win>1 && ( ~isreal(arg) || any(arg<0) ) )
- error( 'pwelch: arg %d (window) vector must be real and >=0',iarg+1);
+ elseif ( is_win>1 && ( ~isreal(arg) ) )
+ error( 'pwelch: arg %d (window) vector must be real',iarg+1);
end
window = arg;
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: Potorti at isti.cnr.it
Web: http://fly.isti.cnr.it/ Key: fly.isti.cnr.it/public.key
More information about the Bug-octave
mailing list