(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

I am suppose to write a program that compares the FFT (Fast Fourier Transform Diagrams) of a sampled signal without the use of a window function and with it. The window function should be as long as the signal and the signal should have N points, N chosen as to not cause leakage of the specter of the signal.

**The window function should be such that it's components diminish from 0 to it's end.

2. Relevant equations

3. The attempt at a solution

I am having troubles applying the window functions because i get some weird output signal from a pretty simple line of code so i'm sure i'm not getting how this is suppose to work in MATLAB. Let's say I am trying to use the triangle window function because im not sure what is meant by the ** condition in the assignment. Maybe that the triangle function should be symmetric on the y axis?

The original signal outputs like this:Code (Matlab M):

f1 = 1000;

f2 = 1270;

fs = 15000;

F1 = 100/1500; %minimum N so i wouldnt have signal leaks on the frequency diagrams.

F2 = 127/1500;

N = 1500;

n = 0:N-1;

x = 8*cos(2*pi*F1*n)+5*cos(2*pi*F2*n);

% i have found that the triangle window function is called with triang(L)

window = triang(N); %length should be N as the signal is of length N

xwindowed=x.*window;

figure

stem(n, x);

pause

figure

stem(n, xwindowed);

pause

and the windowed like this:

which makes no sense and is not how this is suppose to work. What don't i understand here?

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# How to use the window functions on a signal in MATLAB?

Have something to add?

**Physics Forums | Science Articles, Homework Help, Discussion**