% This script demonstrates the effect of too small a time window on the % DFT of a signal that is a sum of sines. % Interval end points t_low = 0; t_high = 1.25; %t_high = 1; %t_high = 2; %t_high = 4; %t_high = 8; % Time step size del_t = 0.01; %del_t = 0.01; %del_t = 0.02; %del_t = 0.04; %del_t = 0.08; % Time Points T = [t_low:del_t:t_high]; % Number of time points N = length(T); % Amplitudes and frequencies of components a1 = 1; w1 = 2*pi; a2 = 1; a2 = 0; w2 = 1*pi; % Construct signal X = a1*sin(w1*T) + a2*sin(w2*T); % Compute the DFT of the signal and the corresponding frequencies. F = fft(X); W = [0:N-1]*2*pi/(N*del_t); % Plot results figure(1); plot(T,X); figure(2); plot(W,abs(F));