SLIDE 13 AxisSet(8); legend(’True Signal’,’Reconstructed Signal’); eval(sprintf(’print -depsc AliasingTones%04d;’,fx(c1))); end; return; n = -15:15; t = -5.5:0.01:5.5; xp = rand(size(n)); % Sampled signal wc = pi; T = 1; xr = zeros(size(t)); % Reconstructed signal subplot(3,1,3); for cnt = 1:length(n), st = (wc*T/pi)*xp(cnt)*sinc(wc*(t-n(cnt)*T)/pi); plot(t,st,’g’); hold on; xr = xr + st; end; h = plot(t,xr,’b’,n,xp,’ro’); set(h(2),’MarkerFaceColor’,’r’); set(h(2),’MarkerSize’,2); hold off; xlim([min(t) max(t)]); ylim([-0.2 1.2]); xlabel(’Time (s)’); ylabel(’Signal’); box off; subplot(3,1,2); plot([min(t) max(t)],[0 0],’k:’); hold on; h = stem(n,xp,’r’); set(h(1),’MarkerFaceColor’,’r’); set(h(1),’MarkerSize’,2);
Portland State University ECE 223 Sampling
51
Example 3:Aliasing of Pure Tones
1 2 3 4 5 6 7 8 9 10 −1 −0.8 −0.6 −0.4 −0.2 0.2 0.4 0.6 0.8 1 Time (ms) Signals (scaled) Aliasing of Pure Tones Example Tone Frequency:2200 Hz Sample Rate:2000 Hz True Signal Reconstructed Signal
Portland State University ECE 223 Sampling
49
hold off; ylabel(’Sampled Signal’); subplot(3,1,1); h = plot(t,xr,’b’,n,xp,’ro’); set(h(2),’MarkerFaceColor’,’r’); set(h(2),’MarkerSize’,2); ylabel(’Reconstructed Signal’); xlim([min(t) max(t)]); ylim([-0.2 1.2]); box off; title(’Example of Band-limited Siganl Reconstruction (Interpolation)’);
Portland State University ECE 223 Sampling
52
Example 3: MATLAB Code
function [] = AliasingTones(); close all; fs = 2e3; % 2 kHz sample rate fx = [500 900 1.1e3 1.5e3 1.8e3 2.2e3]; t = 0:10e-3/500:10e-3; % Span of 5 ms ts = -15e-3:1/fs:25e-3; % Sampled times T = 1/fs; ws = 2*pi*fs; wc = ws/2; for c1 = 1:length(fx), xt = cos(2*pi*fx(c1)*t); % True signal xs = cos(2*pi*fx(c1)*ts); % True signal sampled xr = zeros(size(t)); % Reconstructed signal memory allocation for c2 = 1:length(ts), st = (wc*T/pi)*xs(c2)*sinc(wc*(t-ts(c2))/pi); % Band-limited interpolation xr = xr + st; end; figure; FigureSet(1,’LTX’); h = plot(t*1e3,xt,’b’,t*1e3,xr,’g’,ts*1e3,xs,’ko’); set(h(1),’LineWidth’,1.5); set(h(2),’LineWidth’,0.8); set(h(3),’MarkerFaceColor’,’k’); set(h(3),’MarkerSize’,4); xlim([min(t*1e3) max(t*1e3)]); ylim([-1.1 1.1]); box off; xlabel(’Time (ms)’); ylabel(’Signals (scaled)’); title(sprintf(’Aliasing of Pure Tones Example Tone Frequency:%d Hz Sample Rate:%d Hz’,fx(c1),fs));
Portland State University ECE 223 Sampling
50