Hanning Window of Infinite Sine Wave

4 ビュー (過去 30 日間)
Laura Maybury
Laura Maybury 2019 年 7 月 12 日
回答済み: Kaashyap Pappu 2019 年 7 月 17 日
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!

回答 (1 件)

Kaashyap Pappu
Kaashyap Pappu 2019 年 7 月 17 日
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')

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by