% % Filename: example13.m % % Description: M-file demonstrating the use of the DFT for % approximating continous-time frequency content. % figure(1); clear; clf; % clear memory and figure t = 0:0.0000005:0.00015; % CT and CT signal ft = (1 + cos(2*pi*20000*t)).*cos(2*pi*100000*t); subplot(2,2,1); plot(t,ft); xlabel('t (sec)'); ylabel('f(t)'); title('CT AM Signal'); f = [-100000 100000 -80000 80000 -120000 120000]; F = [pi pi pi/2 pi/2 pi/2 pi/2];% CTFT of CT signal subplot(2,2,2); stem(f,F,'^'); xlabel('f (Hz)'); ylabel('F(f)'); title('CTFT of CT AM Signal'); T = 0.0000025; % compute and plot DT signal k = 0; for m = 0:5:length(ft)-5, fk(k+1) = ft(m+1); kvec(k+1) = k; k = k + 1; end; subplot(2,2,3); stem(kvec,fk,'filled'); xlabel('k'); ylabel('f[k]'); title('f[k] from Sampling CT AM Signal'); fkpad = [fk zeros(1,20)]; % compute & plot padded DT signal kvecpad = [kvec 60:79]; subplot(2,2,4); stem(kvecpad,fkpad,'filled'); xlabel('k'); ylabel('f[k]'); title('Padded f[k]'); figure(2); clf; % open & clear figure 2 Fr = dft(fkpad); % compute and plot DFT mag spectrum r = kvecpad; stem(r/(80*T), abs(Fr),'filled'); xlabel('f = r/NoT (Hz)'); ylabel('|Fr|'); title('Magnitude Spectrum from DFT of Sampled Signal');MATLAB Plot Generated: