% show high pass and low pass filter pairs and their action on a 1d signal % define signal, sample rate, sample domain N = 256; T = (0:1:(N-1))/N; X = 2*cos(5*2*pi*T)+0.5*sin(60*2*pi*T)+ 0.25*sin(100*2*pi*T)+0.5*(2*rand(size(T))-1); %X = cos(5*2*pi*t); %X = sin(30*2*pi*t); SD = 0:(N-1); FD = SD-N/2; % define low and high pass masks lo = [1 1]; lo = lo/sum(lo); hi = [1,-1]; hi = hi/sum(abs(hi)); Xl = circconv(X,lo); Xh = circconv(X,hi); elo = [lo,zeros(1,N-length(lo))]; ehi = [hi,zeros(1,N-length(hi))]; M = max(abs(X)); figure(1); subplot(3,1,1) plot(SD,X) axis([0,N,-M,M]); title('original') subplot(3,1,2) plot(SD,Xl) axis([0,N,-M,M]); title('low pass') subplot(3,1,3) plot(SD,Xh) axis([0,N,-M,M]); title('high pass') figure(2); subplot(3,1,1) plot(FD,fftshift(abs(fft(X)))) axis tight title('|dft(X)|') subplot(3,1,2) plot(FD,fftshift(abs(fft(elo)))) axis tight title('|dft(lo)|') subplot(3,1,3) plot(FD,fftshift(abs(fft(ehi)))) axis tight title('|dft(hi)|')