Convolution Sum Overview
- Review of time invariance
- Review of sampling property
- Discrete-time convolution sum
- Two methods of visualizing
- Some examples
- J. McNames
Portland State University ECE 222 Convolution Sum
- Ver. 1.06
Convolution Sum Overview Review of time invariance Review of - - PowerPoint PPT Presentation
Convolution Sum Overview Review of time invariance Review of sampling property Discrete-time convolution sum Two methods of visualizing Some examples J. McNames Portland State University ECE 222 Convolution Sum Ver. 1.06 1
a = 0.6; n = -2:10; subplot(3,2,1); x1 = (n==0); % Unit impulse centered at n=0 h = stem(n,x1,’b’); set(h(1),’Marker’,’.’); title(’Input’); ylabel(’x_1[n] = \delta[n]’); box off; xlim([min(n) max(n)]); subplot(3,2,2); y1 = (a.^n).*(n>=0); % Unit impulse response h[n] h = stem(n,y1,’r’); set(h(1),’Marker’,’.’); title(’Output’); ylabel(’y_1[n] = h[n]’); box off; xlim([min(n) max(n)]); subplot(3,2,3); x2 = (n==2); % Unit impulse centered at n=2 h = stem(n,x2,’b’); set(h(1),’Marker’,’.’); ylabel(’x_2[n] = \delta[n-2]’); box off; xlim([min(n) max(n)]); subplot(3,2,4); y2 = (a.^(n-2)).*(n>=2); % Unit impulse response h[n] h = stem(n,y2,’r’); set(h(1),’Marker’,’.’); ylabel(’y_2[n] = h[n-2]’); box off; xlim([min(n) max(n)]);
subplot(3,2,5); x3 = (n==5); % Unit impulse centered at 5 h = stem(n,x3,’b’); set(h(1),’Marker’,’.’); xlabel(’Time (n)’); ylabel(’x_3[n] = \delta[n-5]’); box off; xlim([min(n) max(n)]); subplot(3,2,6); y3 = (a.^(n-5)).*(n>=5); % Unit impulse response h[n] h = stem(n,y3,’r’); set(h(1),’Marker’,’.’); xlabel(’Time (n)’); ylabel(’y_3[n] = h[n-5]’); box off; xlim([min(n) max(n)]);
n = -2:10; x1 = 1*(n==0); % Unit impulse centered at n=0 x2 = -1*(n==2); % Unit impulse centered at n=2 x3 = 2*(n==5); % Unit impulse centered at 0 x = x1 + x2 + x3; % The original signal X = [x1;x2;x3;x]; for cnt = 1:4, subplot(4,1,cnt); plot([min(n) max(n)],[0 0],’k:’); hold on; h = stem(n,X(cnt,:),’b’); set(h(1),’Marker’,’.’); hold off; box off; axis([min(n) max(n) min(x) max(x)]); if cnt==1, ylabel(’x_1[n]’); title(’Example of Unit Sampling’); elseif cnt==2, ylabel(’x_2[n]’); elseif cnt==3, ylabel(’x_3[n]’); elseif cnt==4, ylabel(’x[n]’); xlabel(’Time (n)’); end; end;
a = 0.6; n = -2:10; x1 = 1*(n==0); % Unit impulse centered at n=0 x2 = -1*(n==2); % Unit impulse centered at n=2 x3 = 2*(n==5); % Unit impulse centered at 0 x = x1 + x2 + x3; % The original signal y1 = 1*a.^(n-0).*(n>=0); y2 = -1*a.^(n-2).*(n>=2); y3 = 2*a.^(n-5).*(n>=5); y = y1 + y2 + y3; % The original signal X = [x1;x2;x3;x]; Y = [y1;y2;y3;y]; for cnt = 1:4, subplot(4,2,2*cnt-1); plot([min(n) max(n)],[0 0],’k:’); hold on; h = stem(n,X(cnt,:),’b’); set(h(1),’Marker’,’.’); hold off; box off; axis([min(n) max(n) -1 2]); if cnt==1, ylabel(’x_1[n]’); title(’Input’); elseif cnt==2, ylabel(’x_2[n]’); elseif cnt==3, ylabel(’x_3[n]’); elseif cnt==4, ylabel(’x[n]’); xlabel(’Time (n)’); end;
subplot(4,2,2*cnt); plot([min(n) max(n)],[0 0],’k:’); hold on; h = stem(n,Y(cnt,:),’r’); set(h(1),’Marker’,’.’); hold off; box off; axis([min(n) max(n) -1 2]); if cnt==1, ylabel(’y_1[n]’); title(’Output’); elseif cnt==2, ylabel(’y_2[n]’); elseif cnt==3, ylabel(’y_3[n]’); elseif cnt==4, ylabel(’y[n]’); xlabel(’Time (n)’); end; end;
n = 7; k = -5:10; subplot(4,1,1); x = (k==0) - (k==2) + 2*(k==5); % Input Signal plot([min(k) max(k)],[0 0],’k:’); hold on; sh = stem(k,x,’b’); set(sh(1),’Marker’,’.’); hold off; ylabel(’x[k]’); box off; xlim([min(k) max(k)]); subplot(4,1,2); h = ((0.6).^(k)).*((k)>=0); % Unit impulse response h[k] sh = stem(k,h,’g’); set(sh(1),’Marker’,’.’); ylabel(’h[k]’); box off; xlim([min(k) max(k)]); subplot(4,1,3); h = (a.^(-k)).*((-k)>=0); % Unit impulse response h[-k] sh = stem(k,h,’g’); set(sh(1),’Marker’,’.’); ylabel(’h[-k]’); box off; xlim([min(k) max(k)]); subplot(4,1,4); h = (a.^(n-k)).*((n-k)>=0); % Unit impulse response h[-k] sh = stem(k,h,’g’); set(sh(1),’Marker’,’.’); ylabel(’h[7-k]’); xlabel(’Time (k)’); box off; xlim([min(k) max(k)]);
a = 0.6; n = 7; k = -5:10; n = -5:10; y = []; subplot(3,1,1); x = (k==0) - (k==2) + 2*(k==5); % Input Signal plot([min(k) max(k)],[0 0],’k:’); hold on; sh = stem(k,x,’b’); set(sh(1),’Marker’,’.’); hold off; ylabel(’x[k]’); xlabel(’Time (k)’); box off; xlim([min(k) max(k)]); for cnt = 1:length(n), subplot(3,1,2); h = (a.^(n(cnt)-k)).*((n(cnt)-k)>=0); % Unit impulse response h[-k] sh = stem(k,h,’g’); set(sh(1),’Marker’,’.’); st = sprintf(’h[%d-k]’,n(cnt)); ylabel(st); xlabel(’Time (k)’); box off; xlim([min(k) max(k)]);
subplot(3,1,3); m = -5:n(cnt); s = sum(h.*x); % Convolution sum y = [y,s]; plot([min(n) max(n)],[0 0],’k:’); hold on; sh = stem(m,y,’r’); set(sh(1),’Marker’,’.’); hold off; ylabel(’y[n]’); xlabel(’Time (n)’); box off; axis([min(n) max(n) -1 2]); pause; end;
k = -5:10; n = -5:10; x = 3*(k==-2) - 5*(k==-1) + 2*(k==0) -1*(k==3); % Input Signal x[k] y = zeros(size(n)); for cnt = 1:length(n), h = ((n(cnt)-k)>=0) - ((n(cnt)-k)>=5); % Unit Impulse: h[n-k] y(cnt) = sum(x.*h); % Convolution Sum end; subplot(2,1,1); sh = stem(n,y,’r’); set(sh(1),’Marker’,’.’); ylabel(’y[n]’); xlabel(’Time (n)’); box off; set(gca,’YGrid’,’On’); axis([min(n) max(n) min(x) max(x)]);
k = -5:10; n = -5:10; x = 3*(k==-2) - 5*(k==-1) + 2*(k==0) -1*(k==3); % Input Signal x[k] y = zeros(size(n)); for cnt = 1:length(n), h = (0.5).^(n(cnt)-k).*((n(cnt)-k)>=0); % Unit Impulse: h[n-k] y(cnt) = sum(x.*h); % Convolution Sum end; subplot(2,1,1); sh = stem(n,y,’r’); set(sh(1),’Marker’,’.’); ylabel(’y[n]’); xlabel(’Time (n)’); box off; set(gca,’YGrid’,’On’); axis([min(n) max(n) min(x) max(x)]);