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

akash 1

The document is a lab report for a Digital Signal Processing course, detailing the computation of polynomial products and impulse responses using MATLAB. It includes code for determining the coefficients of polynomials, calculating impulse responses for a causal system, and designing low-pass and high-pass filters. The report emphasizes the importance of system stability and provides visualizations of frequency responses and impulse responses.
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)
7 views

akash 1

The document is a lab report for a Digital Signal Processing course, detailing the computation of polynomial products and impulse responses using MATLAB. It includes code for determining the coefficients of polynomials, calculating impulse responses for a causal system, and designing low-pass and high-pass filters. The report emphasizes the importance of system stability and provides visualizations of frequency responses and impulse responses.
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/ 35

Sylhet Engineering College

Lab Report 03
Course Title: Digital Signal Processing Sessional

Course Code: CSE 806


Submission Date: 26/01/2025

Submitted By: Submitted To:


Md. Maruf Ahmed Dr. Md Mohsinur Rahman Adnan
Reg. No: 2019331552 Assistant professor
Group Partner: Department of EEE
Md. Jahirul Islam Shahjalal University of Science and
Reg. No: 2019331536 Technology

Part – A

A.1 Let X1(z)  2  3z 1  4z 2 and X (z)  3  4z 1  5z 2  6z 3 .


Determine X(z)  X1 (z) X2 (z)

Code:

% Define the coefficients of X1(z)


% Polynomial: X1(z) = 2 + 3z^(-1) + 4z^(-2)
coeff_X1 = [2, 3, 4]; % Coefficients of X1(z) in descending powers of z

% Define the coefficients of X2(z)


% Polynomial: X2(z) = 3 + 4z^(-1) + 5z^(-2) + 6z^(-3)
coeff_X2 = [3, 4, 5, 6]; % Coefficients of X2(z) in descending powers of z

% Compute the product X3(z) = X1(z) * X2(z) using convolution


coeff_X3 = conv(coeff_X1, coeff_X2); % Convolution of X1(z) and X2(z)

% Display the coefficients of each polynomial


fprintf('Coefficients of X1(z):\n');
disp(coeff_X1);

fprintf('Coefficients of X2(z):\n');
disp(coeff_X2);

fprintf('Coefficients of X3(z) = X1(z) * X2(z):\n');


disp(coeff_X3);

% Verification and Explanation


fprintf('\nVerification of Results:\n');
fprintf('Manually expanding (2 + 3z^-1 + 4z^-2) * (3 + 4z^-1 + 5z^-2 + 6z^-3):\n');
fprintf('Step-by-step results should align with the conv() function output.\n');

Output:
Coefficients of x1(z):
1 2 3
Coefficients of X2(z):
2 3 4 5
Coefficients of X3(z) = X1(z) * X2(z):
2 7 16 22 22 15

Discussion:

1.Definition of Input Polynomials:

The coefficients of X1(z) = 2 + 3z^(-1) + 4z^(-2) and X2(z) = 3 + 4z^(-1) + 5z^(-2)


6z^(-3) are specified in descending powers of z.
This ensures accurate representation of the polynomials in MATLAB, as MATLAB
requires polynomial coefficients to follow this order.

2.Convolution to Compute X3(z):

X3(z) = X1(z) * X2(z) is calculated using the conv() function. The convolution operation
on the coefficient arrays corresponds to multiplying the polynomials in the z-domain.
The conv() function efficiently handles this process by applying the distributive property
of multiplication and summing up coefficients of terms with the same power of z^(-k).

3.Displaying Results:

The code displays the coefficients of X1(z), X2(z), and X3(z). This allows for
verification of intermediate and final results of the computation.

4.Theoretical Verification:

The code suggests a manual verification step, encouraging users to expand the
polynomial multiplication: (2 + 3z^(-1) + 4z^(-2)) * (3 + 4z^(-1) + 5z^(-2) + 6z^(-3)).
By comparing this manual expansion with the output of the conv() function, users can
confirm the correctness of the convolution operation.

A.2 The transfer function of a causal system is given by H(z) =

Determine the first 10 coefficients of the impulse response of this system.


Code:

% Define the numerator and denominator coefficients of H(z)


numerator = [1, 2]; % Coefficients of 1 + 2z^(-1)
denominator = [1, 0.4, -0.12]; % Coefficients of 1 + 0.4z^(-1) - 0.12z^(-2)

% Set the number of coefficients to calculate


num_coefficients = 10;

% Initialize the impulse response array


impulse_response = zeros(1, num_coefficients);

% Define the input sequence as an impulse


input_signal = [1, zeros(1, num_coefficients - 1)];

% Compute the impulse response using the difference equation


for k = 1:num_coefficients
% Compute the current output based on past outputs and inputs
impulse_response(k) = numerator(1) * input_signal(k) + ...
(k > 1) * numerator(2) * input_signal(max(1, k-1)) - ...
(k > 1) * denominator(2) * impulse_response(max(1, k-1)) - ...
(k > 2) * denominator(3) * impulse_response(max(1, k-2));
end

% Display the impulse response results


fprintf('The first %d coefficients of the impulse response are:\n', num_coefficients);
disp(impulse_response);

Output:

The first 10 coefficients of the impulse response are:

1,1.6, −0.52,0.4,−0.2224,0.13696,−0.081472,0.049024,−0.02938624,0.017637376

Discussion:

1. System Definition:
The transfer function H(z) is expressed using its numerator and denominator coefficients:
H(z) = (1 + 2z^(-1)) / (1 + 0.4z^(-1) - 0.12z^(-2))
The numerator [1, 2] corresponds to 1 + 2z^(-1), while the denominator [1, 0.4, -0.12]
represents 1 + 0.4z^(-1) - 0.12z^(-2).

2. Impulse Input:
The impulse response is obtained by applying an impulse input x(k), where:
x(1) = 1 (impulse input at k = 0)
x(k) = 0 for k > 1.

3. Difference Equation:
The impulse response is iteratively computed using the following difference equation
derived from the transfer function:
y(k) = b1 * x(k) + b2 * x(k-1) - a2 * y(k-1) - a3 * y(k-2)
Here:
- b1 and b2 are the numerator coefficients.
- a2 and a3 are the non-leading denominator coefficients (with a1 normalized to 1).
Conditional evaluations (e.g., k > 1 and k > 2) ensure valid indexing for terms like x(k-1),
y(k-1), and y(k-2).

4. Implementation:
A loop iterates over n = 10 samples to calculate the impulse response. For each sample:
- The current output y(k) (or impulse response at k) is computed based on the present
and past inputs and outputs.
MATLAB's conditional indexing ensures that computations only include valid terms for k
= 1 or k = 2.

5. Results:
The code calculates and displays the first 10 coefficients of the impulse response. These
coefficients characterize the system's time-domain behavior when subjected to an impulse
input:
- If the coefficients decay to zero, the system is stable.
- If the coefficients grow indefinitely, the system is unstable.

% Define the numerator and denominator coefficients of H(z)


numerator = [1, 2]; % Coefficients of 1 + 2z^(-1)
denominator = [1, 0.4, -0.12]; % Coefficients of 1 + 0.4z^(-1) - 0.12z^(-2)

% Set the number of coefficients to calculate


num_coefficients = 10;

% Initialize the impulse response array


impulse_response = zeros(1, num_coefficients);

% Define the input sequence as an impulse


input_signal = [1, zeros(1, num_coefficients - 1)];

% Compute the impulse response using the difference equation


for k = 1:num_coefficients
% Compute the current output based on past outputs and inputs
impulse_response(k) = numerator(1) * input_signal(k) + ...
(k > 1) * numerator(2) * input_signal(max(1, k-1)) - ...
(k > 1) * denominator(2) * impulse_response(max(1, k-1)) - ...
(k > 2) * denominator(3) * impulse_response(max(1, k-2));
end

% Display the impulse response results


fprintf('The first %d coefficients of the impulse response are:\n', num_coefficients);
disp(impulse_response);

Part – B

B.1 Design a system whose impulse response gives a digital


oscillation. [Hint: If you don’t know the exact locations of poles
and zeros, try to calibrate it using SPTOOL]

Code:
% Define system poles
r = 0.95; % Adjusted radius of the poles (slightly less than 1 for stability)
theta = pi / 6; % Modified angle of the poles to change frequency

% Compute the pole locations


p1 = r * exp(1j * theta); % Complex pole
p2 = r * exp(-1j * theta); % Complex conjugate pole

% Define the transfer function H(z)


numerator = 1; % No zeros
denominator = poly([p1, p2]); % Convert poles to polynomial coefficients

% Display the transfer function


disp('Modified Transfer Function H(z):');
tf(numerator, denominator, -1);
% Compute the impulse response manually
n = 40; % Reduced number of samples for faster computation
impulse_response = zeros(1, n); % Initialize impulse response
impulse_response(1) = 1; % First sample is the impulse input (delta function)

% Use the difference equation to compute the response


for k = 3:n
impulse_response(k) = -denominator(2) * impulse_response(k-1) ...
- denominator(3) * impulse_response(k-2);
end

% Plot the impulse response


figure;
stem(0:n-1, impulse_response, 'filled', 'LineWidth', 1.2);
xlabel('n (Samples)');
ylabel('Amplitude');
title('Modified Impulse Response of Digital Oscillation System');
grid on;

% Plot the pole-zero diagram manually


figure;
hold on;
plot(real(p1), imag(p1), 'rx', 'MarkerSize', 12, 'LineWidth', 2); % Plot pole 1
plot(real(p2), imag(p2), 'rx', 'MarkerSize', 12, 'LineWidth', 2); % Plot pole 2
rectangle('Position', [-1 -1 2 2], 'Curvature', 1, 'EdgeColor', 'k', 'LineStyle', '--'); % Unit
circle
xlabel('Real Part');
ylabel('Imaginary Part');
title('Modified Pole Diagram');
grid on;
axis equal;
hold off;

Output:
Transfer Function H(z):
1
----------------------
z^2 - 1.386 z + 0.9604

Sample time: unspecified


Discrete-time transfer function.

Discussion:

1. System Poles:
The system’s behavior is governed by its poles:
The radius r=0.95 determines the magnitude of the poles, which is slightly less than 1. This
ensures the system is stable with damped oscillations, as the poles lie inside the unit circle in
the z-plane.
The angle θ=π/6 specifies the frequency of oscillation. θ corresponds to π/6 radians/sample,
which translates to a normalized frequency of oscillation.
Two complex-conjugate poles are defined:
p1=r.e^iθ, p2=r.e^(-iθ)
These poles describe the system's oscillatory behavior in the time domain.

2. Transfer Function H(z):


The transfer function is defined as:
H(z) = 1 / (1 - a1z^(-1) - a2z^(-2)) where a1 and a2 are the coefficients of the denominator
polynomial derived from the poles using the poly() function.
In this case:
Numerator = 1, meaning the system has no zeros, and the numerator remains constant.
The denominator coefficients are computed from the poles, ensuring an accurate
representation of the system dynamics.

3. Impulse Response Calculation:


The impulse response is calculated using the system's difference equation: y[n] = -a1y[n-1] -
a2y[n-2]
The initial condition is y[1]=1, corresponding to the impulse input.
Subsequent values of y[n] are computed iteratively for n=3 to n=40, reflecting the system's
time-domain response.

4. Impulse Response Characteristics:


The plotted impulse response exhibits damped oscillations due to:
r=0.95: The slight damping (radius less than 1) ensures the oscillations decay over time.
θ=π/6: The oscillation frequency is governed by the angle of the poles.
The response reflects a system that is stable and near oscillatory, which is typical for poles
near but inside the unit circle.

5. Pole-Zero Diagram:
The pole-zero diagram is a graphical representation of the system's dynamics:
The poles (p1 and p2) are plotted as red "x" marks in the complex plane.
The unit circle is displayed as a dashed line, serving as a reference for stability and frequency
analysis.
Since both poles are inside the unit circle, the system is stable.

B.2 Design a simple low pass and a high pass filter. [Hint: If you
don’t know the exact locations of poles and zeros, try to calibrate
it using SPTOOL]

Code:

% Sampling frequency
fs = 1000; % Hz
% Frequency points for visualization
n_points = 512; % Number of frequency points

%% Low-Pass Filter Design


wc_lp = 0.4 * pi; % Normalized cutoff frequency for low-pass (0 to pi scale)

% Low-pass filter numerator and denominator coefficients


numerator_lp = [1]; % Numerator for low-pass filter
denominator_lp = [1 -exp(-wc_lp)]; % First-order filter

% Compute and plot frequency response of low-pass filter


[H_lp, w_lp] = freqz(numerator_lp, denominator_lp, n_points);
figure;
subplot(2, 1, 1);
plot(w_lp * fs / (2 * pi), abs(H_lp), 'LineWidth', 1.5, 'Color', 'b');
title('Low-Pass Filter Frequency Response');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;

% Compute and plot impulse response of low-pass filter


n = 50; % Number of samples
impulse_lp = impz(numerator_lp, denominator_lp, n);
subplot(2, 1, 2);
stem(0:n-1, impulse_lp, 'filled', 'r');
title('Low-Pass Filter Impulse Response');
xlabel('n (Samples)');
ylabel('Amplitude');
grid on;

%% High-Pass Filter Design


wc_hp = 0.6 * pi; % Normalized cutoff frequency for high-pass (0 to pi scale)

% High-pass filter numerator and denominator coefficients


numerator_hp = [1 -1]; % Numerator for high-pass filter
denominator_hp = [1 -exp(-wc_hp)]; % First-order filter

% Compute and plot frequency response of high-pass filter


[H_hp, w_hp] = freqz(numerator_hp, denominator_hp, n_points);
figure;
subplot(2, 1, 1);
plot(w_hp * fs / (2 * pi), abs(H_hp), 'LineWidth', 1.5, 'Color', 'g');
title('High-Pass Filter Frequency Response');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;

% Compute and plot impulse response of high-pass filter


impulse_hp = impz(numerator_hp, denominator_hp, n);
subplot(2, 1, 2);
stem(0:n-1, impulse_hp, 'filled', 'm');
title('High-Pass Filter Impulse Response');
xlabel('n (Samples)');
ylabel('Amplitude');
grid on;

Output:

Discussion:
1. Sampling Frequency:
• The sampling frequency fs=1000 Hz is used to scale the normalized frequencies (in the
range 0 to π) to actual frequency values in Hz.

2. Low-Pass Filter:
(a) Design:
• The cutoff frequency ωc is specified as 0.4π radians/sample, which corresponds to
fc=200 Hz in actual frequency (since ωc=2πfc/fs).
• A simple first-order filter is implemented:
o Numerator: [1], representing a gain of 1 for low frequencies.
o Denominator: [1, -e^(-ωc)] controlling the roll-off behavior beyond the cutoff
frequency.
(b) Frequency Response:
• The magnitude response |H(e^jω)| is computed using freqz(), which calculates the
frequency response of the filter.
• The plot shows:
o A flat passband for frequencies below fc.
o A gradual roll-off beyond the cutoff frequency, as expected for a first-order low-pass
filter.
(c) Impulse Response:
• The impulse response is calculated manually, simulating the system’s output to an
impulse input.
• The response shows an exponentially decaying sequence, characteristic of a first-order
low-pass filter. This response highlights how the filter smooths high-frequency
components.

3. High-Pass Filter:
(a) Design:
• The cutoff frequency ωc=0.6π radians/sample corresponds to fc=300 Hz in actual
frequency.
• A first-order high-pass filter is implemented:
o Numerator: [1, -1], ensuring high-frequency components are passed and low-
frequency components are attenuated.
o Denominator: [1, -e^(-ωc)] controlling the attenuation behavior in the stopband.
(b) Frequency Response:
• The frequency response plot shows:
o Significant attenuation of frequencies below fc=300 Hz.
o A flat passband for higher frequencies, consistent with high-pass filter behavior.
(c) Impulse Response:
• The impulse response exhibits an alternating pattern, indicating the emphasis on rapid
changes in the input signal. This is characteristic of high-pass filters, which enhance high-
frequency components.

4. Comparison of Filters:
(a) Frequency Selectivity:
• The low-pass filter allows frequencies below 200 Hz to pass while attenuating higher
frequencies.
• The high-pass filter passes frequencies above 300 Hz, attenuating lower frequencies.
(b) Impulse Responses:
• The low-pass filter’s impulse response is smooth and decays exponentially, reflecting its
smoothing effect on signals.
• The high-pass filter’s impulse response alternates in sign, emphasizing sharp transitions
and high-frequency details.
Part – C

C.1 Determine the system function and the response for a) unit
step b) unit impulse input described by the difference equation-
(assume a causal LTI system)
y(n) = y(n - 1) + x(n)

Looking only the pole-zero plot of Y(Z), state whether


the system will be stable. Comment on ROC.

Code:

% Define the transfer function H(z) = z / (z - 1)


numerator = [1 0]; % Coefficients of z (numerator: z)
denominator = [1 -1]; % Coefficients of z (denominator: z - 1)

% Create the transfer function using the tf function


H = tf(numerator, denominator, -1); % -1 specifies z-domain

% Plot pole-zero plot


figure;
pzplot(H);
title('Pole-Zero Plot');

% Unit Impulse Input (delta(n)) - Z-transform is 1


x_impulse = [1]; % Impulse is 1 at n = 0
y_impulse = filter(numerator, denominator, x_impulse); % System response

% Unit Step Input (u(n)) - Z-transform is 1 / (1 - z^-1)


x_step = [1]; % Unit step input (starts at n=0)
y_step = filter(numerator, denominator, x_step); % System response

% Display the responses


disp('Response to Unit Impulse Input:');
disp(y_impulse);

disp('Response to Unit Step Input:');


disp(y_step);

% Plot the impulse response


figure;
stem(0:length(y_impulse)-1, y_impulse);
title('Response to Unit Impulse Input');
xlabel('n');
ylabel('y(n)');

% Plot the step response


figure;
stem(0:length(y_step)-1, y_step);
title('Response to Unit Step Input');
xlabel('n');
ylabel('y(n)');

Output:
Discussion:

1. Transfer Function:
The transfer function describes a system that has a single pole at z=1 and a zero at the
origin (z=0). These characteristics are evident from the numerator and denominator
coefficients:
 The numerator defines a zero at the origin.
 The denominator defines a pole at z=1, indicating an unstable system because the pole
lies on the boundary of the unit circle.

2. Pole-Zero Plot:
The pole-zero plot provides a graphical representation of the system's dynamics in the
z-domain. The pole at z=1suggests that the system exhibits unbounded growth in
response to certain inputs, reflecting instability. The zero at the origin influences how
the system attenuates or amplifies signals at various frequencies.

3. Impulse Response:
The response to a unit impulse input (δ(n)) is calculated using the filter function.
Since the transfer function is unstable, the impulse response grows without bound.
This behavior aligns with the pole's location at z=1, where the system repeatedly
accumulates the input value instead of settling to a steady state. The plotted impulse
response illustrates this unbounded growth, highlighting the instability of the system.

4. Step Response:
The response to a unit step input (u(n)) is also computed using the filter function. The
step response, like the impulse response, exhibits unbounded growth due to the
system's pole at z=1. The plotted step response shows a steadily increasing output,
consistent with the theoretical behavior of an unstable system.
5. System Behavior:
The primary characteristic of this system is its instability. A pole at z=1 causes
unbounded growth in both the impulse and step responses. This behavior indicates
that the system cannot be used in practical applications unless the instability is
addressed through modifications, such as pole shifting or stabilization techniques.

C.2 Determine the system function and the unit sample response
for a stable LTI system described by the difference equation

y(n)=0.5y(n-1)+x(n)+0.3x(n-1)

Comment on ROC.

Code:

% Define the coefficients of the system function H(z)


numerator = [1 1/3]; % Coefficients of z + 1/3
denominator = [1 -1/2]; % Coefficients of z - 1/2

% Create the transfer function H(z)


H = tf(numerator, denominator, -1); % -1 specifies Z-domain

% Display the pole-zero plot


figure;
pzplot(H);
title('Pole-Zero Plot of H(z)');
xlabel('Re');
ylabel('Im');

% Impulse response (unit sample response)


n = 0:10; % Time index
h = (4/3) * (1/2).^n; % Impulse response h(n) = (4/3)(1/2)^n

% Plot the impulse response


figure;
stem(n, h, 'filled');
title('Impulse Response h(n)');
xlabel('n');
ylabel('h(n)');

% Theoretical verification (System function H(z))


disp('System Function H(z) = (z + 1/3) / (z - 1/2)');
disp('Unit Sample Response h(n) = (4/3) * (1/2)^n u(n)');

Output:

System Function H(z) = (z + 1/3) / (z - 1/2)


Unit Sample Response h(n) = (4/3) * (1/2)^n u(n)

Discussion:

1. Transfer Function and System Characteristics:


The transfer function H(z) defines the system's response to input signals in the zzz-
domain:
 The numerator [1 1/3] specifies a zero at z=−1, influencing the system's frequency
response.
 The denominator [1 −1/2]specifies a pole at z=1/2, which lies within the unit circle,
indicating that the system is stable.
The stability is confirmed by the pole location within the unit circle in the pole-zero plot.
The pole determines the exponential decay rate of the impulse response, while the zero
shapes the system's frequency-selective behavior.

2. Pole-Zero Plot:
The pole-zero plot provides a graphical representation of the system's dynamics in the z-
domain:
 The pole at z=1/2 indicates that the impulse response will decay exponentially with a
factor of (1/2)n.
 The zero at z=−1/3 modifies the system's gain and introduces a specific spectral shaping.
This visualization is a key tool for understanding the system's stability and its influence
on different frequency components.

3. Impulse Response:
The impulse response h(n) is computed analytically as h(n)=(4/3)(1/2)n for n≥0n. This
response:
 Reflects the system's reaction to a unit impulse input.
 Exhibits exponential decay due to the pole at z=1/2, with the rate of decay governed by
the pole's magnitude.
 Demonstrates stability, as the response diminishes over time instead of growing
unbounded.
The impulse response is plotted for n=0 to n=10, clearly illustrating the decay pattern.

4. System Verification:
The code includes theoretical verification by displaying the system's transfer function and
the formula for its impulse response. This ensures consistency between the analytical
derivation and the MATLAB implementation.

5. System Behavior:
This system acts as a simple low-pass filter, where the pole location determines the
smoothing effect. The zero at z=−1/3 slightly modifies the spectral characteristics,
enhancing certain frequency components while attenuating others.

C.3 An LTI system is characterized by the system transfer


−1
3−4 z
function −1
1−3.5 z + 1.5 z
−1

Specify the ROC of H(z) and determine h(n) for the following
conditions:
(a) The system is causal, (b) The system is anticausal, & (c) The
system is noncausal.

For which case, the system is stable?

Code:

% Define the coefficients of the denominator and numerator


denominator = [1 -3.5 1.5]; % Coefficients of the denominator polynomial
numerator = [3 -4]; % Coefficients of the numerator polynomial

% Find the poles of the system (roots of the denominator)


poles = roots(denominator);

% Display the poles


disp('Poles of H(z):');
disp(poles);

% Plot the poles and zeros


figure;
zplane(numerator, denominator);
title('Pole-Zero Plot of H(z)');
xlabel('Re');
ylabel('Im');

% Compute ROC for different cases


roc_causal = max(abs(poles)); % ROC for causal system: |z| > 3
roc_anticausal = min(abs(poles)); % ROC for anticausal system: |z| < 0.5
roc_noncausal = [min(abs(poles)), max(abs(poles))]; % ROC for noncausal system:
0.5 < |z| < 3

disp(['ROC for causal system: |z| > ', num2str(roc_causal)]);


disp(['ROC for anticausal system: |z| < ', num2str(roc_anticausal)]);
disp(['ROC for noncausal system: ', num2str(roc_noncausal(1)), ' < |z| < ',
num2str(roc_noncausal(2))]);

% Stability check
is_stable = all(abs(poles) < 1); % System is stable if all poles are inside the unit
circle
if is_stable
disp('The system is stable.');
else
disp('The system is unstable.');
end

Output:

Poles of H(z):
3.0000
0.5000

ROC for causal system: |z| > 3


ROC for anticausal system: |z| < 0.5
ROC for noncausal system: 0.5 < |z| < 3
The system is unstable.

Discussion:

1. System Representation:
The transfer function H(z) is defined by its numerator and denominator coefficients.
The denominator describes the system's poles, while the numerator describes the
zeros. These poles and zeros determine the system's dynamic and frequency-selective
behavior.

2. Pole-Zero Analysis:
The roots of the denominator polynomial correspond to the poles of H(z), which are
critical for analyzing system stability and causality. The code uses roots to compute
the pole locations and zplane to visualize the pole-zero plot.
 The pole-zero plot reveals the system's behavior in the zzz-domain.
 Poles closer to the unit circle indicate signals that decay slowly, while poles outside the
unit circle represent instability.

3. Region of Convergence (ROC):


The ROC describes the range of z-values for which the system's Z-transform
converges. It depends on whether the system is causal, anticausal, or noncausal:
 For a causal system, the ROC is outside the outermost pole (∣z∣>3).
 For an anticausal system, the ROC is inside the innermost pole (∣z∣<0.5).
 For a noncausal system, the ROC lies between the poles (0.5<∣z∣<3).
These ROCs are essential for determining the system's applicability to different types
of inputs and outputs.

4. System Stability:
Stability is determined by the pole locations:
 If all poles lie strictly within the unit circle (∣z∣<1), the system is stable and its impulse
response converges.
 If any pole lies on or outside the unit circle, the system is unstable.
In this case, the poles at z=3 and z=0.5 indicate that the system is unstable, as the pole
at z=3 is outside the unit circle.

2
z
C.4 An LTI system is given by 2
z −2.5 z +1
Make the system stable assuming the system (a) causal and (b)
anticausal.

Code:

% Define the coefficients for the numerator and denominator for causal and
anticausal systems
% Causal System: H(z) = z^2 / (z^2 - 0.5z + 1)
numerator_causal = [1 0 0]; % z^2
denominator_causal = [1 -0.5 1]; % z^2 - 0.5z + 1

% Anticausal System: H(z) = z^2 / (z^2 - 2.5z + 0.5)


numerator_anticausal = [1 0 0]; % z^2
denominator_anticausal = [1 -2.5 0.5]; % z^2 - 2.5z + 0.5

% Define the transfer function for both systems


H_causal = tf(numerator_causal, denominator_causal, -1); % Causal system transfer
function
H_anticausal = tf(numerator_anticausal, denominator_anticausal, -1); % Anticausal
system transfer function

% Display the transfer function for both cases


disp('Causal System Transfer Function H(z):');
disp(H_causal);

disp('Anticausal System Transfer Function H(z):');


disp(H_anticausal);

% Plot the frequency response (magnitude and phase) for both systems
figure;
subplot(2, 1, 1);
bode(H_causal); % Plot Bode plot for causal system
title('Causal System Frequency Response');

subplot(2, 1, 2);
bode(H_anticausal); % Plot Bode plot for anticausal system
title('Anticausal System Frequency Response');

Discussion:

1. System Definitions:
The two systems analyzed are:
 Causal System: The transfer function H(z)has a denominator with poles placed such that
the system can operate in a causal manner. Causality implies that the system's output at
any time depends only on the current and past input values.
 Anticausal System: The transfer function H(z) has a denominator with poles configured
to emphasize future input values. Anticausality is less common in practical applications
but is relevant in theoretical studies and specific control scenarios.
2. Transfer Function Representation:
Both systems are defined in terms of their numerator and denominator coefficients.
These coefficients describe the behavior of the system in the z-domain. For the causal
system, the poles are closer to the unit circle and allow for a stable causal response.
For the anticausal system, the poles are placed further away, influencing the response
differently.

3. Frequency Response Analysis:


The code computes and plots the frequency responses of both systems using Bode
plots:
 The magnitude response shows how the system amplifies or attenuates signals at different
frequencies.
 The phase response indicates the phase shift introduced by the system at various
frequencies.
In the causal system, the frequency response demonstrates behavior typical of a
system with stability conditions met for a causal configuration. The anticausal system,
by contrast, displays a response indicating a dependence on future values, with a
potential for instability depending on the pole locations.

4. Comparison of Causal and Anticausal Systems:


The main differences between the two systems lie in:
 Pole Configuration: The poles in the causal system are positioned to ensure stability for a
causal response, while the anticausal system has poles suited for a different operational
scenario.
 Frequency Response: The causal system exhibits a stable and predictable response across
frequencies, whereas the anticausal system may show irregular or less conventional
characteristics, depending on the pole placement.

Output:
C.5 Write a generalized program in MATLAB which takes the
coefficients of the denominator of a system transfer function as
input and tests the system stability by Schür Cohn stability test
method.

Code:

% Generalized program for Schur-Cohn Stability Test

function isStable = schurCohnStabilityTest(denominator)


% Input: denominator - Coefficients of the denominator polynomial of the system
% Output: isStable - 1 if the system is stable, 0 otherwise

% Length of the denominator polynomial


n = length(denominator);

% Initializing the Schur-Cohn array


S = zeros(n, n);

% Step 1: First column (using denominator coefficients)


S(1, :) = denominator;

% Step 2: Construct the Schur-Cohn array recursively


for k = 2:n
for m = k:n
% Apply the Schur-Cohn recursion relation
S(k, m) = (S(k-1, m-1) * S(k-1, m) - S(k-1, m)^2) / S(k-1, m-1);
end
end

% Display the Schur-Cohn array


disp('Schur-Cohn Array:');
disp(S);

% Step 3: Check the stability criterion (All values in last row should be positive)
if all(S(end, :) >= 0)
disp('The system is stable.');
isStable = 1; % Stable system
else
disp('The system is unstable.');
isStable = 0; % Unstable system
end
end

% Example usage
% Define the denominator coefficients of the system transfer function
denominator = [1 -1.5 0.7]; % Example: z^2 - 1.5z + 0.7
isStable = schurCohnStabilityTest(denominator);

Output:

Schur-Cohn Array:
1.0000 -1.5000 0.7000
0 -3.7500 1.0267
0 0 1.3077

The system is stable.


Discussion:

1. Input and Setup:


 The input to the function is the set of coefficients of the denominator polynomial of the
system's transfer function, representing the system's poles.
 Stability is determined by recursively constructing a Schur-Cohn array based on these
coefficients.
2. Schur-Cohn Array Construction:
 The algorithm starts with the denominator coefficients as the first row of the array.
 Subsequent rows are calculated using a recursive relation that incorporates both the
current and previous elements of the array.
3. Stability Criterion:
 The system is considered stable if all entries in the final row of the Schur-Cohn array are
non-negative. This condition implies that all poles of the system are within the unit circle.

C.6 A system is described by the following difference equation:

5
y ( n )=
2
y(n-1)-y(n-2)+x(n)

From the pole-zero plot determine the ROC of H(z) for all the
possible cases –
✓ Determine and plot the impulse response of the system if h(n)
is absolutely summable.
✓ Cascade another system with the previous one to get both a
causal and a stable system. Determine the new ROC from the
pole-zero plot of the cascaded system and plot the impulse
response.

Code:

% Define the poles and coefficients


z1 = 2.780; % First pole
z2 = 0.720; % Second pole

% Define the impulse response for a causal system


n = 0:20; % Time index for impulse response
A = 1; % Coefficient for first pole
B = 1; % Coefficient for second pole
% Impulse response calculation (for causal system)
h = A * z1.^n + B * z2.^n;

% Plot the impulse response


figure;
stem(n, h, 'filled');
title('Impulse Response h(n) of the System');
xlabel('n');
ylabel('h(n)');
grid on;

% Define the new poles for the cascaded system


z3 = 0.5; % Pole from the second system

% Plot the poles of the cascaded system


figure;
zplane([1 0 0], [1 -2.780 0.720], 'r');
hold on;
zplane([1], [1 -0.5], 'g');
title('Pole-Zero Plot of the Cascaded System');
legend('Cascaded System 1', 'Second System');
grid on;

Output:

Discussion:
1. Impulse Response:
 The exponential growth or decay of the impulse response highlights the stability of the
original system based on the pole magnitudes.
 The choice of coefficients A and B influences the amplitude but not the stability of the
response.
2. Effect of Cascading:
 The pole z3 from the second system introduces additional dynamics to the system. If z3
lies inside the unit circle, the cascaded system is more likely to remain stable.
3. Visualization:
 The pole-zero plot is a critical tool for understanding system behavior. It provides a
graphical interpretation of the system’s stability and potential resonance points.

C.7 For a system depicted below:

✓ Determine the system functions and the ROC of the causal


system blocks required to get the two desired output signals
shown in the diagram.
✓ Show the response of all the digital systems in the same plot.

Code:

% Parameters
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
t = 0:T:1-T; % Time vector (1 second duration)
f = 10; % Frequency of sine wave (Hz)
A = 1; % Amplitude of sine wave
noise_power = 0.01; % AWGN power

% Input signal: Sine wave with AWGN


sine_wave = A * sin(2 * pi * f * t);
awgn_noise = sqrt(noise_power) * randn(size(t));
input_signal = sine_wave + awgn_noise;

% Digital System 1: Low Pass Filter (LPF)


cutoff_freq = 20; % LPF cutoff frequency (Hz)
[b, a] = butter(4, cutoff_freq / (Fs / 2)); % 4th-order Butterworth filter
LPF_output = filter(b, a, input_signal);

% Non-inverting Zero Crossing Detector (ZCD)


ZCD_output = LPF_output > 0; % Binary output: 1 if signal > 0, 0 otherwise

% Digital System 2: Edge Detector


edge_detector_output = diff(ZCD_output); % Detect edges (positive and negative)
edge_detector_output = [0, edge_detector_output]; % Adjust size to match time
vector

% Digital System 3: Triangular Wave Generator


triangular_wave = cumsum(edge_detector_output); % Integrate edge detector
output
triangular_wave = triangular_wave - mean(triangular_wave); % Center the
waveform

% Plot results
figure;
subplot(5, 1, 1);
plot(t, input_signal);
title('Input Signal (Sine wave + AWGN)');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(5, 1, 2);
plot(t, LPF_output);
title('LPF Output');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(5, 1, 3);
plot(t, ZCD_output);
title('Zero-Crossing Detector Output');
xlabel('Time (s)');
ylabel('Binary Output');

subplot(5, 1, 4);
plot(t, edge_detector_output);
title('Edge Detector Output');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(5, 1, 5);
plot(t, triangular_wave);
title('Triangular Wave Generator Output');
xlabel('Time (s)');
ylabel('Amplitude');

% Adjust plot layout


sgtitle('System Responses');

Output:

Discussion:
Input Signal:
1. Sine Wave with Noise:
o The input signal combines a sine wave with additive white Gaussian noise
(AWGN). This simulates real-world signals where noise is present alongside the
desired signal.

Low-Pass Filter (LPF):


2. Purpose:
o The low-pass filter smooths the signal by removing higher frequency noise,
allowing the underlying sine wave to be more clearly visible.
3. Output:
o The filtered output shows a cleaner version of the sine wave, with less noise.

Zero-Crossing Detector (ZCD):


4. Functionality:
o The ZCD detects when the signal crosses zero, providing a binary output of
positive and negative values.
5. Impact:
o The ZCD simplifies the signal by turning it into a binary form, highlighting
changes in sign.

Edge Detector:
6. Operation:
o The edge detector identifies transitions in the ZCD output, marking key points of
change in the signal.
7. Output:
o This process emphasizes points where the signal significantly changes, such as
peaks and troughs.

Triangular Wave Generator:


8. Concept:
o The triangular wave generator uses cumulative sums of the edge detector output
to form a continuous triangular waveform.
9. Result:
o The final output is a smooth triangular waveform, built from the discrete edge
detection events.

Visualization:
10. Results Analysis:
o Each stage provides insight into different aspects of the signal, from smoothing
out noise to identifying key events. The final triangular wave combines these
events into a continuous form.
11. Implications:
o This process highlights how digital signal processing techniques can effectively
handle noisy signals and transform them into useful data for analysis or control
applications.

C.8 The transfer function of a system is given below. Check its


stability.
1
H ( z )=
1 3 1 y
1−z−1+ z −2− z−4 + z−5 + z−6 − z−7
2 4 8 13

Code:

% Define the coefficients of the denominator polynomial D(z)


D_coeffs = [1, -1/2, 1/2, 0, -3/4, 1, 1/8, -9/13];

% Find the poles of the system (roots of D(z))


poles = roots(D_coeffs);

% Check magnitudes of the poles


is_stable = all(abs(poles) < 1);

% Display results
disp('Poles of the system:');
disp(poles);

if is_stable
disp('The system is stable: All poles are inside the unit circle.');
else
disp('The system is unstable: Some poles are outside the unit circle.');
end

% Plot poles on the z-plane


figure;
zplane([], poles); % No zeros, only poles
title('Poles of the System on the z-plane');
xlabel('Real Part');
ylabel('Imaginary Part');
grid on;
Output:

Poles of the system:


-0.0843 + 1.1757i
-0.0843 - 1.1757i
0.6998 + 0.6521i
0.6998 - 0.6521i
0.8391 + 0.0000i
-0.7851 + 0.1807i
-0.7851 - 0.1807i

The system is unstable: Some poles are outside the unit circle.

Discussion:

Poles of the System:


1. Definition:
o The poles are calculated as the roots of the denominator polynomial
D(z)=[1,−1/2,1/2,0,−3/4,1,1/8,−9/13].
2. Stability Check:
o The system is stable if all poles lie within the unit circle (i.e., their magnitude is
less than 1).

Analysis:
3. Poles:
o The roots of D(z) represent the system's poles.
o These poles determine the system's response and stability.
4. Stability:
o By checking the magnitudes of the poles, it is determined whether the system is
stable or not.
o If all poles are within the unit circle, the system is stable; otherwise, it is unstable.

Visualization:
5. Z-Plane Plot:
o The z-plane plot graphically displays the poles of the system.
o The plot shows their real and imaginary components, providing a clear view of
their locations relative to the unit circle.

You might also like