You are on page 1of 32

EXERCISES

1. Given the given signal x(n),


X(n) = {-2 4 -1 -3 5 8 2 -5}

Hint: Commands to display x(n) at t=0

X = [-2 4 -1 -3 5 8 2 -5]; %magnitude of the signal


t = 0: length(x)-1; %extracting length of signal starting at t=0
stem(t-2,x); %display signal at t=0

Display the discrete waveform in the given expression below.


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

b. X(-n)
Syntax:
>> stem(-(t-3),x,'m')
c. X(-n+3)
Syntax:
>> stem(-(t-3)-3,x,'m')

d. 3x(n+4)
Syntax:
>> stem((t-3)-4,3*x,'m')

e. -2x(n-3)
Syntax:
>> stem((t-3)+3,-2*x,'m')
f. X(3n+2)
Syntax:
>> stem(((t-3)-2)/3,x,'m')

g. 4x(3n-2)
Syntax:
>> stem(((t-3)+2)/3,4*x,'m')

2. Plot the signals x(n) and h(n). Determine the value for y(n) which is equivalent to signals x(n) and
h(n) and display resulting waveform.

Answer:

Y(n) = [-2 -4 1 -7 0 6 0 -2 -4 -3 1 6]
X(n)
Syntax:
>> x=[-2 0 -1 -3 1 2 -2 -3];
>> t=0:length(x)-1;
>> stem(t-3,x,'m')
h(n)
Syntax:
>> h=[1 2 -1 1 -2];
>> n=-4:0;
>> stem(n,h,'m')

Y(n)
Syntax:
>> y=conv(x,h)

y=

-2 -4 1 -7 0 6 0 -2 -4 -3 1 6

>> n=-8:3

n=

-8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3

>> stem(n,y,'m')

3. Syntax:
>> z=[3 3 2];
>> roots(z)

ans =

-0.5000 + 0.6455i
-0.5000 - 0.6455i

Syntax:
>> z1=[4 -9 0 8 -10];
>> roots(z1)
ans =

2.0649 + 0.0000i
-1.1204 + 0.0000i
0.6528 + 0.8090i
0.6528 - 0.8090i

4. Syntax:
>> x1=[-5 -3 -5 -3];
>> poly(x1)

ans =

1 16 94 240 225

Syntax:
>> x2=[4 3 5 -2];
>> poly(x2)

ans =

1 -10 23 34 -120

5. Syntax:
>> a1=[4 2 -1 3];
>> s=[3 -2 1];
>> b1=poly(s)

b1 =

1 -2 -5 6

>> [h,i,j]=residue(a1,b1)

h=

12.6000
-1.2667
-1.3333

i=
3.0000
-2.0000
1.0000

j=

Syntax:
>> [b2,a2]=residue(h,i,j)

b2 =

4.0000 2.0000 -1.0000 3.0000

a2 =

1.0000 -2.0000 -5.0000 6.0000

6. Syntax:
>> LABUNG=audiorecorder(11025,16,1);
>> recordblocking(LABUNG,5);
>> play(LABUNG)

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 LABUNG


>> y1=getaudiodata(LABUNG);
>> plot(y1,'m')

B. Plot the signal

C. Syntax: >> play(LABUNG)

D.
Syntax:
>> Fs3=11025;
>> Yfft=fft(y1,512);
>> w=(0:255)/256*(Fs3/2);
>> figure;plot(w,abs([Yfft(1:256)]),'m');
7. Syntax:
>> Fs2=11025;
>> [B,A]=fir1(6,[2000]/(Fs2/2))
>> zplane(B,A)

Syntax:
>> impz(B,A)

Syntax:
>> freqz(B,A)
Syntax:
>> Fs4=11025;
>> lowfilter=filter(B,A,y1);
>> LowF=fft(lowfilter,512);
>> w1=(0:255)/256*(Fs4/2);
>> plot(w1,abs([LowF(1:256)]),'m')
>> lowpassf=audioplayer(lowfilter,Fs4);
>> play(lowpassf);

8. Syntax:
>> Fs5=11025;
>> [B,A]=fir1(6,[1000]/(Fs5/2),'high')

B=

-0.0083 -0.0444 -0.1309 0.8103 -0.1309 -0.0444 -0.0083

A=

>> zplane(B,A,'m')

Syntax:
>> impz(B,A)
Syntax:
>> freqz(B,A)

9. Syntax:
>> Fs7=11025;
>> [D,C]=fir1(30,[2500 3000]/(Fs7/2),'bandpass')
>> zplane(D,C)

Syntax:
>> impz(D,C)
Syntax:
>> freqz(D,C)

You might also like