% The University of Queensland % School of Information Technology & Electrical Engineering % COMS3100/7100 Introduction to Communications % Generate graphs which demonstrate the Gibbs effect for the sinc % function % Define the array of radian frequencies at which we will sample % the successive approximations to the DTFT omega = -pi:pi/1024:pi; % The DTFT of the sinc function is a square wave in the frequency % domain --- we define this now X = zeros(1, 2049); X(513:1536) = 2; % The graphs will be drawn in a for loop. We define here the list % of values for M which we use in the loop, as well as the the colour % codes for each of the plots Mlist = [1, 3, 7, 19]; colourlist = ['r', 'g', 'b', 'm']; % Now for the main loop in which each of the graphs are drawn for i = 1:4, % Get the value of M for this graph and generate n, the list of % time-domain samples M = Mlist(i); n = -M:M; % Generate the matrix whose elements are n omega, n increasing down % the columns, omega across the rows nomega = n' * omega; % To generate X_M, we need only multiply a row vector of the % time-domain samples of x[n] by the matrix whose rows are % complex exponentials (the complex exponents of the elements % of nomega, defined above) XM = sinc(n / 2) * exp(j * nomega); % Now follows the actual plotting commands subplot(2, 2, i); % First plot the Mth order approximation to the DTFT, X_M[e^jw] plot(omega / pi, real(XM), colourlist(i)); hold on; % Then also plot the function X[e^jw] to which the approximations % converge plot(omega / pi, X, 'k:'); hold off; % Set up labels and ensure uniform scaling on each graph xlabel('\fontname{times}\it\omega\rm (\times \pi)'); ylabel(['\fontname{times}\itX\rm_{', num2str(M), '}(\ite^{j\omega}\rm)']); xlim([-1, 1]); ylim([-0.5, 2.5]); end;