TX00CQ31 –Digital Signal Processing

Study 2: Time Domain


Read the lab instructions first!

Number

Questions

Write your answer in this column

Hints

1

Generate an impulse response function of a running average filter with length 60.

Commands:

ss = 60;

oo = ones(1, ss);

run_ave_filter = oo / ss;

ones

2

Filter-function is an implementation of a linear, time-invariant system in Octave. It can be used to produce output of a FIR-system the following way:
    yy = filter(hh, 1, xx)
    where hh is the impulse response and xx the input signal
Use filter function to generate the unit step response for the average filter of the previous exercise.

Commands:

yy = filter(run_ave_filter, 1, oo);


stem plot

filter

3

An easy way to produce a delayed signal in Octave, is to use the filter-function the following way:
    filter([zeros(1,N),1],1,xx)
Test this method to produce signal
    delta[n-60]

Commands:

delayed_yy = filter([zeros(1,60),1],1,oo);


stem plot

filter
zeros

4 a

Use appropriate test vectors to check if  the system

y[n] = x[n]*en

 is

  • Linear

Commands to verify linearity:

n = -10:10;

a = rand(1, 1); b = rand(1, 1);

x1 = rand(1, length(n)); x2 = rand(1, length(n));

y1 = (a * x1 + b * x2) .* exp(n);

y2 = a * (x1 .* exp(n)) + b * (x2 .* exp(n));


Justification:

y[n] is linear, because the linearity equations provide the same values for both sides (y1-y2 is zero) and superposition is only possible in linear systems.


stem plot

Linearity: use two, random test vectors x1 and x2, and two random numbers to see if
    F{a*x1 + b*x2} = a*F{x1} + b*F{x2}
This method does not provide a proof of linearity, but detects quite efficiently non-linear systems. However, computing accuracy may play tricks on you, so be aware. 

4 b

  • Time Shift Invariant

Commands to verify time shift invariant:

n = 0:30;

x = n >= 0;

y = x .* exp(n);

y1_delayed = [zeros(1,5), y];

N = 0:35;

x_shifted(N >= k) = 1;

y2_delayed = x_shifted .* exp(N);

y_difference = y2_delayed - y1_delayed;


Justification:

The larger the n, the larger the difference of D{F{x}} and F{D{x}}, which implies that the system is time variant.


stem plot

Time-shift invariance: use step function to see if time shifted input results in an output equal to time shifted original output
    D{F{x}} = F{D{x}}
where D{} is a delay operator. This method does not provide a proof of time-shift invariance, but it works darn well in reality

4 c

  • Causal

Commands to verify causality:

n = -10:20;

u = n >= 0;

for i = 1:length(n)

q(i) = rand();

end

x = u .* q;

y = x .* exp(n);

stem(n, y);


Justification:

The system is causal, because on there is no non-zero output before input.


stem plot

Causality: use a random signal, which starts at origin as your test signal to see if the system gives non-zero output before input
    F{u[n]*q[n]} = 0, when n < 0
This method does not provide a proof of causality, but it works darn well in reality

4 d

  • Stable

Commands to verify stability:

n = -30:30;

x = n >= 0;

syms x

L = limit(x .* exp(x),x,inf)

Output:

L = (sym) oo


Justification:

As n approaches infinity, the output approaches infinity as well. Thus the system is not stable.

Stable: test, if the  step response converges
    | lim(F{u[n]}) | <= A
This works much better than the absolute sum of impulse response!

5

System difference equation is:
y[n] = x[n]-1.2*x[n-1]+x[n-2]-0.5*y[n-1]

Generate 60 points long impulse response function h[n].
Is the system FIR or IIR?


stem plot

Commands:

n = 0:59;

x = n >= 0;

y = filter([0,-0.5],[1,-1.2,1], x);


Justification:

It is an IIR system, because it never returns to zero.

filter
stem

6

Write an m-function, which returns discrete delta function values for a given index vector.

Commands:

function m = delta_func(n)

m = (n == 0);