Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

DSP ASSignment

‫محمد علي الصديق علي‬


Index : 154087
Question ( 1 ) :

code:

% first sinusoid

fs = 400

t = 0:0.1:100 % we chose the time range of the signal to respresent

x1 = cos(2*3.14*60*t + pi/3) % this is the orginal continous sinusoid

ts = 0:10:100

x1 = cos(2*3.14*60*ts/fs + pi/3) % this is the sampled sinusoid

stem(ts,x1)

% second sinusoid

x2 = cos(2*3.14*340*ts/fs - pi/3)

stem(ts,x2)

%third sinsoid

x3 = cos(2*3.14*460*ts/fs + pi/3)
stem(ts,x3)

- in the first sinusoid the sampling frequency is greater than twice

the component frequency so the sampling process succeeded and there


were no loss

if it is converted back .

- in the second sinusoid the sampling frequency was less than twice the
component

frequency so the sampling didnt succeed without loss , and an aliasing


happened also

some frequencies in the original signal may be lost if the signal is


converted back to

continous time.

in the third sinusoid the sampling frequency is too lower than twice the
component frequency and alot of

aliasing will happen and majority of the original signal is lost and cant
be reconstructed back ,also we cant get

any usefull information


First function
Second function

Third function

Question ( 3 ) :

% for rectangle pulse input

% we represent the unit step functions in matlab in range up to 100

n = 1:1:100

un1 = [ones(1,100)]
un2 = [zeros(1,29) ones(1,71)]

% for the delayed n-1 part we reprensent :

un3 = [zeros(1,1) ones(1,99)]

un4 = [zeros(1,30) ones(1,70)]

Y = 5*( un1 - un2 ) - 5*(un3 - un4)

in1 = 5*( un1 - un2 ) % input

stem(n,Y) %plot the output

hold on

stem(n,in1) % plot the input

title('Rectangle pulse')

hold off

% second triangle pulse

unn1 = [ones(1,100)]

unn2 = [zeros(1,19) ones(1,81)]

unn3 = [zeros(1,39) ones(1,61)]

% n-1 part

unn4 = [zeros(1,1) ones(1,99)]

unn5 = [zeros(1,20) ones(1,80)]

unn6 = [zeros(1,40) ones(1,60)]


Y2 = (n .*(unn1 - unn2 ) + (40-n) .*(unn2 - unn3)) - (n .*(unn4 - unn5 ) +
(40-n) .*(unn5 - unn6))

in2 = (n .*(unn1 - unn2 ) + (40-n) .*(unn2 - unn3)) % input

stem(n,Y2) %plot the output

hold on

stem(n,in2) % plot the input

title('triangle pulse')

hold off

% sinusoidal pulse

n2 = 1:1:1000 % we increase the range up to 1000

uns1 = [ones(1,1000)]

uns2 = [zeros(1,99) ones(1,901)]

% n-1 :

uns3 = [zeros(1,1) ones(1,999)]

uns4 = [zeros(1,100) ones(1,900)]

Y3 = (15*sin(3.14*n2/25) .*( uns1 - uns2)) - (15*sin(3.14*n2/25) .*(


uns3 - uns4))

in3 = (15*sin(3.14*n2/25) .*( uns1 - uns2)) % input

stem(n2,Y3) %plot the output

hold on
stem(n2,in3) % plot the input

title('sinusoidal pulse')

hold off

in the output plots appear they are related to the input derivative

the output result can be used to insert value to the left of a point and

evaluate derivatives in some interval.


Question ( 3 ) :

code:

% first we modify the function to a more appropriate form b y


multiplying

% the numerator and denominator by Z^6

z = tf('z')
H = z^6/( z^6 - 0.5*z^5 + 0.2*z^4 - 0.1*z^3 + 0.007*z^2 + 0.14*z + 0.15)

m = linspace(-10,10) % taking the range between -10 and 10

num = [1]

den = [1,-0.5,0.2,-0.1,0.007,0.14,0.15]

respon = freqz(num,den,m)

plot(m,respon)

- there are 3 osciallations that means there are 3 conjugate poles and
because the oscialltions are kind of sharp

that means they are close to the unit circle.

- (B) sketch pole-zero from magnitde plot :

from oscialltions we have 3 poles with conjugates

total poles = 6
Sketched Poles and zeros .

True poles and zeros:

You might also like