BASIC SIGNAL PROCESSING ECE 2526 MOBILE COMMUNICATION Monday
BASIC SIGNAL PROCESSING ECE 2526 -MOBILE COMMUNICATION Monday, 08 April 2018
CONVOLUTION / 01 • EXAMPLE Write a Matlab routine to calculate and display the output of a linear system with impulse response h(t) and input x(t) which are all triangular signals of the shape shown below.
CONVOLUTION / 02 t 1 = -1 : 0. 001 : 1; tri = tripuls(t 1, 2); plot(t 1, tri, ’r’); y = tripuls(T, w) generates a triangular pulse of width w
CONVOLUTION / 02 t 1= -1 : 0. 001 : 1; tri=tripuls(t 1, 2); c=conv(tri, tri); t 2=-2: 0. 001: 2; c = conv(u, v) Returns the convolution of plot(t 2, c, 'r'); vectors u and v.
DESIGN OF FILTER / 01 •
DESIGN OF FILTER / 02 •
DESIGN OF FILTER / 03 a=[1, -1, 0. 9]; b=[1]; n=[-20: 120]; x=[zeros(1, 20), 1, zeros(1, 120)]; h=filter(b, a, x); y = filter(b, a, x) Filters the input data, x, using a stem(n, h, 'r'); rational transfer function defined by the numerator and denominator title(‘Impulse Response') coefficients b and a, respectively.
FILTER DESIGN EXAMPLE 2 / 01 •
FILTER DESIGN EXAMPLE 2 / 02 fs= 100; t = 0 : 1/fs : 1; x = sin(2*pi*t*3)+. 25*sin(2*pi*t*40); b = ones(1, 10)/10; y = filter(b, 1, x); plot(t, x, 'b', t, y, 'r') y = filter(b, a, x) Filters the input data, x, using a rational transfer function defined by the numerator and denominator coefficients b and a, respectively.
DISCRETE FOURIER TRANSFORM EXAMPLE / 01 • Find DTFS for periodic discrete-time signal x[n] with period N=30
DISCRETE FOURIER TRANSFORM EXAMPLE / 02 x=[1, 1, zeros(1, 28)]; N=30; n=0: N-1; Y = fft(x) and y = ifft(X) a=(1/N)*fft(x); implement the transform and inverse transform real_part=real(a); pair given for vectors of subplot(2, 1, 1); length N. stem(n, real_part, 'r'); xlabel('k'); ylabel('real(a)'); subplot(2, 1, 2); imag_part=imag(a); stem(n, imag_part); xlabel('k') ylabel('imag(a)');
FREQUENCY RESPONSE EXAMPLE /01 Find the frequency response of a 10 -point averaging lowpass FIR filter and plot it’s magnitude and phase.
FREQUENCY RESPONSE EXAMPLE /02 X = ones(n, classname) b = ones(1, 10)/10; returns an n-by-n array of ones of data type classname. a=1; [H omega]=freqz(b, a, 100, 'whole'); mag. H=abs(H); freqz returns the frequency response based subplot(2, 1, 1); on the current filter coefficients. plot(omega, mag. H, 'r'); grid; ang. H=angle(H); subplot(2, 1, 2); plot(omega, ang. H/pi, 'r'); grid
SPECTRUM / 01 Find the spectrum of the following signal: f=0. 25+2 sin(2π5 k)+sin(2π12. 5 k)+1. 5 sin(2π20 k)+0. 5 sin(2π35 k)
SPECTRUM / 02 N=256; % number of samples T=1/128; % sampling frequency=128 Hz k=0: N-1; time=k*T; f=0. 25+2*sin(2*pi*5*k*T) +1*sin(2*pi*12. 5*k*T) +1. 5*sin(2*pi*20*k*T) +0. 5*sin(2*pi*35*k*T); subplot(2, 1, 1); plot(time, f, 'r'); title('Signal sampled at 128 Hz'); F=fft(f); mag. F=abs([F(1)/N, F(2: N/2)/(N/2)]); hertz=k(1: N/2)*(1/(N*T)); subplot(2, 1, 2); stem(hertz, mag. F, 'r'); title('Spectrum')
SPECTRUM OF A SIGNAL WITH ADDITIVE NOISE Objective: Find the spectrum of a signal buried in noise. Procedure: 1. Create a signal consisting of 50 Hz and 120 Hz sinusoids and sampled at 1, 000 Hz. 2. Corrupt the signal with random noise.
SPECTRUM OF A NOISY SIGNAL/02 t = 0: 0. 001: 0. 6; x = sin(2*pi*50*t) + sin(2*pi*120*t); y = x + 2*randn(1, length(t)); subplot(2, 1, 1); plot(y(1: 50), 'r'); Y = fft(y, 512); Pyy= Y. *conj(Y)/512; Y = fft(X, n) f = 1000*(0: 255)/512; Returns the n-point DFT. fft(X) is equivalent to fft(X, n) where n is the size of X in the first subplot(2, 1, 2); nonsingleton dimension. If the length of X is less than n, X is padded with trailing zeros to plot(f, Pyy(1: 256), 'r') length n.
UPSAMPLING & DOWNSAMPLING A VECTOR x = [1 2 3 4 5 6 7 8 9 10]; y = upsample(x, 2); y 1=downsample(x, 2); subplot(3, 1, 1); stem(x); title('Original Data'); subplot(3, 1, 2); stem(y); title('Up Sample'); subplot(3, 1, 3); stem(y 1); title('Down Sample');
UPSAMPLING & DOWNSAMPLING A 2 D MATRIX x = [1 2 3; 4 5 6; 7 8 9; 10 11 12]; x 1 = x y = downsample(x, 3) -----------------------------X 1 = 1 2 3 4 5 6 7 8 9 10 11 12 y= 1 2 10 11 3 12
- Slides: 19