0% found this document useful (0 votes)
10 views

DSP_LAB_07_Linear Systems, Time-Invariance, and Signal Transformations

use in descrte time and frequenct domain

Uploaded by

iqratariqkhan12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

DSP_LAB_07_Linear Systems, Time-Invariance, and Signal Transformations

use in descrte time and frequenct domain

Uploaded by

iqratariqkhan12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Digital Signal Processing -LAB Manual

Linear Systems, Time-Invariance, and Signal Transformations

1. Objective
This lab is designed to help students:

 Understand and verify the properties of linearity and time invariance in systems.
 Distinguish between linear and non-linear systems.
 Perform basic signal operations: time shifting, time scaling, and time reversal (flipping).
 Visualize system behavior and transformations using MATLAB.

2. Theory
2.1 Linearity

A system is linear if it satisfies both:

 Additivity: T{x₁[n] + x₂[n]} = T{x₁[n]} + T{x₂[n]}


 Homogeneity (Scaling): T{a·x[n]} = a·T{x[n]}

If both conditions are met, the system is linear.

2.2 Time Invariance

A system is time-invariant if a shift in the input causes an identical shift in the output.
Mathematically:
If y[n] = T{x[n]}, then the system is time-invariant if T{x[n - n₀]} = y[n - n₀].

2.3 Signal Transformations

 Time Shifting: x[n - k] shifts the signal by k units.


 Time Reversal (Flipping): x[-n] reflects the signal about n = 0.
 Time Scaling: x[an] compresses or stretches the signal (in discrete time, scaling is less common due
to indexing).

3. MATLAB Implementation
matlab
CopyEdit

1|Page
1
Digital Signal Processing -LAB Manual

% Lab 2: LTI Systems, Linearity, Time Invariance, and Signal Transformations


clc; clear; close all;

%% Time Axis
n = -10:10;

%% Define Signal
x = double(n >= 0 & n <= 5); % A rectangular pulse

%% 1. Signal Transformations
x_shift = double((n - 3) >= 0 & (n - 3) <= 5); % x[n-3]
x_flip = double(-n >= 0 & -n <= 5); % x[-n]
x_scale = double(round(n / 2) >= 0 & round(n / 2) <= 5); % x[n/2] approx

figure('Name','Signal Transformations','NumberTitle','off');
subplot(2,2,1); stem(n, x, 'filled'); title('Original Signal x[n]'); grid on;
subplot(2,2,2); stem(n, x_shift, 'filled'); title('Time Shifted x[n-3]'); grid
on;
subplot(2,2,3); stem(n, x_flip, 'filled'); title('Time Reversed x[-n]'); grid on;
subplot(2,2,4); stem(n, x_scale, 'filled'); title('Time Scaled x[n/2]'); grid on;

%% 2. System Definitions
% System A: y[n] = x[n] + 2
% System B: y[n] = n * x[n]
% System C: y[n] = x[n] + x[n-1] (Linear and Time-Invariant - FIR)

%% Inputs for testing linearity


x1 = double(n >= 0 & n <= 3);
x2 = double(n >= -2 & n <= 1);
a = 2; b = -1;
input_comb = a*x1 + b*x2;

% System C (FIR)
T = @(x) x + [0 x(1:end-1)]; % Causal FIR: x[n] + x[n-1]

% Apply system
y1 = T(x1);
y2 = T(x2);
y_comb = T(input_comb);
sum_y = a*y1 + b*y2;

% Compare results
figure('Name','Linearity Test (System C)','NumberTitle','off');
subplot(2,1,1); stem(n, y_comb, 'filled'); title('T{a·x1 + b·x2}');
subplot(2,1,2); stem(n, sum_y, 'filled'); title('a·T{x1} + b·T{x2}');

fprintf('Checking linearity: If both plots are equal, the system is linear.\n');

%% 3. Time Invariance Test


shifted_input = double((n - 2) >= 0 & (n - 2) <= 3);
y_original = T(x1); % Output for x1
y_shifted_input = T(shifted_input); % Output for shifted x1
shifted_output = [0 0 y_original(1:end-2)]; % y[n-2]

figure('Name','Time Invariance Test','NumberTitle','off');


subplot(2,1,1); stem(n, y_shifted_input, 'filled'); title('T{x[n-2]}');
subplot(2,1,2); stem(n, shifted_output, 'filled'); title('y[n-2]');

fprintf('Checking time invariance: If both plots match, the system is time-


invariant.\n');

2|Page
2
Digital Signal Processing -LAB Manual

4. Lab Tasks
1. Use the plots to determine whether System C is linear and time-invariant.
2. Modify the system to y[n] = x[n]^2 and repeat the linearity test. Is the system still linear?
3. Try a different input signal (e.g., a sine or exponential) and repeat the signal transformations.

5. Home Task / Assignment


Task:

1. Define a new system: y[n] = sin(x[n]) and test whether it is linear and time-invariant.

Linearity Test:

A system is linear if it satisfies additivity and homogeneity:

 Let x1[n]→y1[n]=sin (x1[n])


 Let x2[n]→y2[n]=sin (x2[n])

Check:
ax1[n]+bx2[n]→y[n]=sin(ax1[n]+bx2[n]) ≠ a sin(x1[n]) + b sin(x2[n])

Since sine is nonlinear,

Time-Invariance Test:

Shift input:
Let x[n−n0] → y[n]= sin(x[n−n0])
Compare with shifting output:
Original output: y[n]=sin(x[n])
Shifted output: y[n−n0] =sin(x[n−n0])

Since both are the same.

2. For the signal x[n] = (0.9)^n * u[n], perform and plot:


o Time shift: x[n - 4]
o Time flip: x[-n]
o Combined: x[-n + 3]

Code:

% Define range for n

n = -10:20;

% Original signal x[n] = (0.9)^n * u[n]

3|Page
3
Digital Signal Processing -LAB Manual

x = (0.9).^n .* (n >= 0);

% Time shift: x[n - 4]

x_shift = (0.9).^(n - 4) .* (n - 4 >= 0);

% Time flip: x[-n]

x_flip = (0.9).^(-n) .* (-n >= 0);

% Combined: x[-n + 3] = x[3 - n]

x_combined = (0.9).^(3 - n) .* (3 - n >= 0);

% Plotting

figure;

subplot(4,1,1);

stem(n, x, 'filled');

title('Original: x[n] = (0.9)^n * u[n]');

xlabel('n'); ylabel('x[n]'); grid on;

subplot(4,1,3);

stem(n, x_flip, 'filled');

title('Time Flip: x[-n]');

xlabel('n'); ylabel('x[-n]'); grid on;

subplot(4,1,4);

stem(n, x_combined, 'filled');

title('Combined: x[-n + 3]');

xlabel('n'); ylabel('x[-n + 3]'); grid on;

4|Page
4
Digital Signal Processing -LAB Manual

Original: x[n] = (0.9) n * u[n]


1

x[n]
0.5

0
-10 -5 0 5 10 15 20
n
Time Shift: x[n - 4]
1
x[n - 4]

0.5

0
-10 -5 0 5 10 15 20
n
Time Flip: x[-n]
1
x[-n]

0.5

0
-10 -5 0 5 10 15 20
n
Combined: x[-n + 3]
1
x[-n + 3]

0.5

0
-10 -5 0 5 10 15 20
n

3. Write a short paragraph: Why are LTI systems important in DSP?

LTI systems are essential in DSP because their linearity and time-invariance simplify
analysis, design, and implementation. They enable efficient filtering, stable system behavior,
and straightforward use of tools like convolution and Fourier transforms.

5|Page
5

You might also like