You are on page 1of 17

Guanzing, Jacob Christian P.

ECE107L/E04

1. Given the signal x(n)


X(n) = { -2 4 -1 -3* 5 8 2 -5}
D
Display the discrete waveform in the given expression below
a. X(n)
b. X(-n)

Syntax:
>> x = [-2 4 -1 -3 5 8 2 -5];
>> t = 0: length(x)-1;
>> stem(-(t-3),x,'m-<');

c. X(-n+3)

Syntax:
>> x = [-2 4 -1 -3 5 8 2 -5];
>> t = 0: length(x)-1;
>> stem(-(t-3)+3,x,'m-<');
d. 3X(n+4)

Syntax:
>> x = [-2 4 -1 -3 5 8 2 -5];
>> t = 0: length(x)-1;
>> stem((t-3)+4,3*x,'m-<');

e. -2X(n-3)

Syntax:
>> x = [-2 4 -1 -3 5 8 2 -5];
>> t = 0: length(x)-1;
>> stem((t-3)-3,-2*x,'m-<');
f. X(3n+2)

Syntax:
>> x = [-2 4 -1 -3 5 8 2 -5];
>> t = 0: length(x)-1;
>> stem(3*(t-3)+2,x,'m-<');

g. 4X(3n-2)

Syntax:
>> x = [-2 4 -1 -3 5 8 2 -5];
>> t = 0: length(x)-1;
>> stem(3*(t-3)-2,4*x,'m-<');
2. Plot the signals x(n) and h(n). Determine the value for y(n) which is equivalent to convolve
signals x(n) and h(n) and display resulting waveform
3. Solve the roots of the following equation
a. 3x2 + 3x + 2 = 0
Syntax:
>> p = [3 3 2];
>> r = roots(p)
r=

-0.5000 + 0.6455i
-0.5000 - 0.6455i
b. 4x4 - 9 x3 + 8x – 10 = 0
Syntax:
>> p = [4 -9 8 -10];
>> r = roots(p)
r=

1.8914 + 0.0000i
0.1793 + 1.1356i
0.1793 - 1.1356i
4. Find the polynomial expression given the following factors
a. (x + 5)(x + 3) (x + 5)(x +3)
Syntax:
>> r = [-5 -3 -5 -3];
>> p2 = poly(r)
p2 =

1 16 94 240 225
b. (x - 4)(x - 3)(x - 5)(x + 2)
Syntax:
>> r = [4 3 5 -2];
>> p2 = poly(r)

p2 =

1 -10 23 34 -120
5. Expand the expression below using partial fraction expansion
a. (4s3 + 2s2 – s + 3)/(s-3)(s+2)(s-1)
Syntax:
>> r = [3 -2 1];
>> p2 = poly(r);
>> p1 = [4 2 -1 3];
>> [r,p,k] = residue(p1,p2)
r=

12.6000
-1.2667
-1.3333

p=

3.0000
-2.0000
1.0000

k=

4
b. Now, convert the partial fraction expansion back to polynomial coefficients. What did you
obtain? Is this similar to your original signal?
Syntax:

>> [p1,p2] = residue(r,p,k)

p1 =

4.0000 2.0000 -1.0000 3.0000

p2 =

1.0000 -2.0000 -5.0000 6.0000

>> r = roots(p2)

r=

-2.0000
3.0000
1.0000

Ans. Yes, it is the same as the original signal.

6.
a. Using your microphone record a 5-second audio saying “Digital Signal Processing” with
sampling frequency of 11025Hz.
Syntax:
>> Guanzing = audiorecorder(11025,16,1);
>> recordblocking(Guanzing, 5);
>> play(Guanzing)

ans =

audioplayer with properties:

SampleRate: 11025
BitsPerSample: 16
NumberOfChannels: 1
DeviceID: -1
CurrentSample: 257
TotalSamples: 55125
Running: 'on'
StartFcn: []
StopFcn: []
TimerFcn: []
TimerPeriod: 0.0500
Tag: ''
UserData: []
Type: 'audioplayer'

>> save Guanzing


>> y = getaudiodata(Guanzing);
>> plot(y,'m-<')

b. Plot the signal you recorded.


c. Play your audio signal. Give comments.
d. Using fft command, plot the frequency contents of your signal.
Syntax:
>> Y = fft(y,512);
>> w = (0:255)/256*(11025/2);
>> plot(w,abs((Y(1:256))),'m-<');

7. Create a lowpass FIR filter with 6th order filter, cutoff frequency of 2000 Hz and sampling
frequency of 11025Hz. Determine the filter coefficients. Plot the poles and zeroes of the filter,
its impulse response, and its frequency response.

Syntax:
>> [b,a] = fir1(6,2*2000/11025)

b = -0.0027 0.0426 0.2535 0.4130 0.2535 0.0426 -0.0027


a= 1

Pole-Zero Plot
Syntax:
>>pz = zplane(b,a,'m');
Impulse Response Graph
Syntax:
>> [H,T]=impz(b,a);
>> stem(T,H,'m<')

Magnitude Response Graph:


Syntax:
>> freqz(b,a);

c. Filter your original signal using lowpass filter created earliler. Plot the frequency content
of the filtered signal. Describe the waveform.
Syntax:
>> FS = 11025;
>> LF = filter(b,a,y);
>> fftLow = fft(LF,512);
>> w = (0:255)/256*(FS/2);
>> plot(w,abs(fftLow(1:256)),'m');
d. Play audio signal and describe what you hear.
8. Generate a high pass 6th order FIR filter with a cutoff frequency of 1000 Hz. Plot the poles and
zeroes of the filter, its impulse response, and magnitude response. Provide filter coefficients.
Syntax:
>> FS = 11025;
>> FC = 1000;
>> i = FC/(FS/2);
>> [b,a] = fir1(6,i,'high')

b = -0.0083 -0.0444 -0.1309 0.8103 -0.1309 -0.0444 -0.0083


a= 1

Pole-Zero Plot
Syntax:
pz = zplane(b,a,'m');
Impulse Response Graph
Syntax:
>> [H,T]=impz(b,a);
>> stem(T,H,'m<')

Magnitude Response Graph


Syntax:
>> freqz(b,a)
e. Filter your original signal using highpass filter created earlier. Plot the frequency content
of the filtered signal. Describe the waveform.
Syntax:
>> LF = filter(b,a,y);
>> fftHigh = fft(LF, 512);
>> w = (0:255)/256*(FS/2);
>> plot(w,abs(fftHigh(1:256)),'m');

9. Generate bandpass FIR filter with 30th filter oder, cutoff frequencies of 2.5 kHz and 3kHz. Plot
the poles and zeroes of the filter and magnitude response.
Syntax:
>> [b,a] = fir1(30,2*[2500 3000]/11025)

b = -0.0002 -0.0057 0.0004 0.0135 -0.0008 -0.0299 0.0013 0.0545 -0.0017 -0.0837
0.0017 0.1115 -0.0013 -0.1316 0.0005 0.1390 0.0005 -0.1316 -0.0013 0.1115
0.0017 -0.0837 -0.0017 0.0545 0.0013 -0.0299 -0.0008 0.0135 0.0004 -0.0057 -
0.0002

a= 1
Pole-Zero Plot
Syntax:
pz = zplane(b,a,'m');
Impulse Response Graph
Syntax:
>> [H,T]=impz(b,a);
>> stem(T,H,'m<')

Magnitude Response Graph


Syntax:
>> freqz(b,a)
a. Filter your original signal using bandpass filter created earlier. Plot the frequency content
of the filtered signal. Describe the waveform.
Syntax:
>>FS = 11025
>> LF = filter(b,a,y);
>> fftBP = fft(LF, 512);
>> w = (0:255)/256*(FS/2);
>> plot(w,abs(fftBP(1:256)),'m');

10. Generate a stop band FIR filter order, cutoff frequency of 1.5k Hz and 3k Hz, plot the poles and
zeroes of the filter, its impulse response the its frequency response.
Syntax:
>> [b,a] = fir1(30,2*[1500 3000]/11025,'stop')

b = -0.0004 0.0008 -0.0022 -0.0077 0.0004 0.0173 0.0095 -0.0072 0.0072 -0.0063 -
0.0822 -0.0542 0.1415 0.1936 -0.0744 0.7290 -0.0744 0.1936 0.1415 -0.0542 -
0.0822 -0.0063 0.0072 -0.0072 0.0095 0.0173 0.0004 -0.0077 -0.0022 0.0008 -
0.0004

a= 1
Pole-Zero Plot
Syntax:
pz = zplane(b,a,'m');
Impulse Response Graph
Syntax:
>> [H,T]=impz(b,a);
>> stem(T,H,'m<')

Magnitude Response Graph


Syntax:
>> freqz(b,a)
Results and Discussion
Generating discrete signals in MATLAB can be performed by setting the number of
samples on t, defining x(n) values, and using the stem( ) command. The discrete signal can be also
manipulated by changing the values of t (for n) and x (for x(n)) in the stem( ) function. Also, The
roots of a function can be found using the roots ( ), and from roots to polynomial expression its
poly( ). The function residue( ) will get the partial fraction of the signal.
For the finite impulse response filtering, the plot of the unfiltered audio signal looks like
some normal audio recording. Using FIR filter, the output of the lowpass filter looks like the signal
was decreasing from the graph. A high pass filter shows the graph is increasing on a very sinusoidal
manner, and for the bandpass, it looks like only a single loud pulse was made.

Conclusion and Recommendation


On the first objective, to perform plotting the discrete time signal, we need to define
explicitly the X(n) values, and the time with respect to n. Only then after we can perform plotting
the discrete time signal with the MATLAB function stem( ).
On the second objective, performing root extraction, root to polynomial, and partial
fraction, we define the polynomial as an array of the constant multiplied by the coefficients of the
function from the highest order to lower order. Then we simply use root(poly) to extract the roots
of the function. For the conversion, we define the roots of the function in any order, only then
after we can use poly( ) to convert it back to polynomial; a variable containing the coefficients of
the function from the highest.
On the third objective, to learn use FIR filter on lowpass, highpass, bandpass, and
stopband filter, we can use filter ( ), fft( ), and fir1( ).

You might also like