Hanning Window of Infinite Sine Wave

3 visualizaciones (últimos 30 días)
Laura Maybury
Laura Maybury el 12 de Jul. de 2019
Respondida: Kaashyap Pappu el 17 de Jul. de 2019
Hello,
I am a complete Matlab novice and am trying to show how the application of a Hanning window to an infinite sine wave can produce a finite wave. There are many examples of this online (in pictorial format) but I want to understand how it is done.
Any help would be grately appreciated!

Respuestas (1)

Kaashyap Pappu
Kaashyap Pappu el 17 de Jul. de 2019
Hi,
The Hanning Window coefficients can be generated using the “hann” function. The operation of the function is defined in the documentation here: https://in.mathworks.com/help/signal/ref/hann.html
The code below is a template on how to use the window sequences:
windowLength = 45; %Length of hanning window
w = hann(windowLength); %Function to generate hanning window coefficients
fs = 200; %Sampling Frequency
t = 0:1/fs:999; %Generate sample points for entire duration-999 seconds
f=25; %Sine wave frequency
output = sin(2*pi*f*t); %Sine wave of long duration
figure(1)
plot(t(1:100),output(1:100)) %Plotting the first 100 samples of sine wave
xlabel('Time in Seconds')
ylabel('Amplitude')
title('Before Windowing')
index = 34; %Starting index for windowing
windowSequence = [zeros(1,index-1) w' zeros(1,length(output)-index-length(w)+1)]; %Windowing Sequence of same duration as sine wave
winOut = output.*windowSequence; %Product of sequences to perform windowing
figure(2)
plot(t(1:100),winOut(1:100)) %Resulting plot of windowing - first 100 samples
xlabel('Time in Seconds')
ylabel('Amplitude')
title('After Windowing')
figure(3)
stem(w) %Visualizing Window function
xlabel('n')
ylabel('w(n)')
title('Window')

Categorías

Más información sobre Octave en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by