Está en la página 1de 13

Ventaneo

Se utiliza con el fin de evitar que las discontinuidades introducidas al analizar solo una fraccin de la seal o al introducir muestras con valor de cero introduzcan componentes de alta frecuencia en el espectro, que son mas bien un artificio de las discontinuidades introducidas y no de la seal. Ya que la transformada rpida de Fourier asume que la seal es peridica, es conveniente siempre hacerle un procedimiento de ventaneo a la seal con la que se quiere trabajar. MATLAB cuenta con diferentes tipos de ventanas como:

Hamming Hanning Bartlett Blackman Boxcar Triangular Gauss Blackmanharris Kaiser Dolph-Chebyshev

Ventana Hamming
w=wavread('danih.wav'); h=hamming(length(w)); x=w.*h; subplot(3,1,1),plot(w),grid on, zoom,title('hola.wav') subplot(3,1,2),plot(h),grid on, zoom,title('ventana hamming') subplot(3,1,3),plot(x),grid on, zoom,title('multiplicacion de hola con la ventana hamming')

Sonido y resultado despus de pasarlo pro la ventana Hamming Ahora visualizamos el espectro esp=abs(fft(x); plot(esp),title('Espectro con la Ventana Hamming'),grid on, zoom on

Espectro del sonido despus de pasarlo por la ventana Compare el sonido original con el sonido resultante

Ventana Hanning

w=wavread('danih.wav'); h=hanning(length(w)); x=w.*h; subplot(3,1,1),plot(w),grid on, zoom,title('hola.wav') subplot(3,1,2),plot(h),grid on, zoom,title('ventana hanning') subplot(3,1,3),plot(x),grid on, zoom,title('multiplicacion de hola con la ventana hanning')

Sonido y resultado despus de pasarlo pro la ventana Hanning

Ahora visualizamos el espectro

esp=abs(fft(x); plot(esp),title('Espectro con la Ventana Hanning'),grid on, zoom on

Espectro del sonido despus de pasarlo por la ventana

Compare el sonido original con el sonido resultante

Ventana Kaiser
w=wavread('danih.wav'); h=kaiser(length(w), 0.2); x=w.*h; subplot(3,1,1),plot(w),grid on, zoom,title('hola.wav') subplot(3,1,2),plot(h),grid on, zoom,title('ventana kaiser') subplot(3,1,3),plot(x),grid on, zoom,title('multiplicacion de hola con la ventana kaiser')

Sonido y resultado despus de pasarlo pro la ventana kaiser Ahora visualizamos el espectro esp=abs(fft(x); plot(esp),title('Espectro con la Ventana kaiser'),grid on, zoom on

Espectro del sonido despus de pasarlo por la ventana

from Wavelet Scale Spectra by Charles Rino Compute wavelet scale spectra from segmented discrete wavelet transform (Screenshot). WindowFT(sig,w,m,Name,titl)
function specgm = WindowFT(sig,w,m,Name,titl) % WindowFT -- Window Fourier Transform % Usage % specgm = WindowFT(sig,w,m,Name,titl) % Inputs % sig 1-d signal % w window half-length, default = n/2 % m inter-window spacing, default=1 % Name string: 'Rectangle', 'Hanning', 'Hamming', % 'Gaussian', 'Blackman'; Default is 'Rectangle' % titl Optional Title String Modifier % Outputs % specgm Window Fourier Transform of sig, n+1 by n complex matrix % Side Effects % Image Plot of the Window Fourier Transform % Description % Algorithm % supposes signal is non-periodic, i.e. zero-padded % Example % sig = ReadSignal('Caruso'); % sig = sig(1:128); % specgm = WindowFT(sig); % See Also % MakeWindow IWindowFT % References % Mallat, "A Wavelet Tour in Signal Processing"; % 4.2.3 Discrete Windowed Fourier Transform. % sig = sig(:); n = length(sig); f = [zeros(n,1); sig; zeros(n,1)]; % Default parameters, if nargin < 2, w = n/2; end; if nargin < 3, m=1; end; if nargin < 4, Name = 'Rectangle'; end; if nargin < 5, titl = []; end; % Initialize output matrix,

nw = floor(n ./ m); specgm = zeros(n,nw); ix = ((-w):w); win = MakeWindow(Name,w); win = win(:); % Computing Window Fourier Transform for l=1:nw, totseg = zeros(1,3*n); t = 1+ (l-1)*m; tim = n + t + ix; seg = f(tim); seg = seg.*win; totseg(tim) = seg; localspec = fft(totseg(n+1:2*n)); specgm(:,l) = localspec(1:n)'; %window = rshift(window')'; end % % Make Window Fourier Transform Display specgmShow = abs(specgm(1:(n/2+1),:)); spmax = max(max(specgmShow)); spmin = min(min(specgmShow)); colormap(1-gray(256)) image(linspace(0,n,n),linspace(0,n/2,n/2+1),256*(specgmShowspmin)/(spmax-spmin)); axis('xy') xlabel('') ylabel('Frequency') if nargout==0, specgm = []; end % % Copyright (c) 1996. Xiaoming Huo % % Modified by Maureen Clerc and Jerome Kalifa, 1997 % clerc@cmapx.polytechnique.fr, kalifa@cmapx.polytechnique.fr

% % % % % %

Part of Wavelab Version 850 Built Tue Jan 3 13:20:43 EST 2006 This is Copyrighted Material For Copying permissions see COPYING.m Comments? e-mail wavelab@stat.stanford.edu

Search R20

MATLAB MATLAB Examples

FFT for Spectral Analysis


This example shows the use of the FFT function for spectral analysis. A common use of FFT's is to find the frequency components of a signal buried in a noisy time domain signal. First create some data. Consider data sampled at 1000 Hz. Start by forming a time axis for our data, running from t=0 until t=.25 in steps of 1 millisecond. Then form a signal, x, containing sine waves at 50 Hz and 120 Hz.
t = 0:.001:.25; x = sin(2*pi*50*t) + sin(2*pi*120*t);

Add some random noise with a standard deviation of 2 to produce a noisy signal y. Take a look at this noisy signal y by plotting it.
y = x + 2*randn(size(t)); plot(y(1:50)) title('Noisy time domain signal')

Clearly, it is difficult to identify the frequency components from looking at this signal; that's why spectral analysis is so popular. Finding the discrete Fourier transform of the noisy signal y is easy; just take the fastFourier transform (FFT).
Y = fft(y,251);

Compute the power spectral density, a measurement of the energy at various frequencies, using the complex conjugate (CONJ). Form a frequency axis for the first 127 points and use it to plot the result. (The remainder of the points are symmetric.)
Pyy = Y.*conj(Y)/251; f = 1000/251*(0:127); plot(f,Pyy(1:128)) title('Power spectral density') xlabel('Frequency (Hz)')

Zoom in and plot only up to 200 Hz. Notice the peaks at 50 Hz and 120 Hz. These are the frequencies of the original signal.
plot(f(1:50),Pyy(1:50)) title('Power spectral density') xlabel('Frequency (Hz)')