0% found this document useful (0 votes)
12 views37 pages

Jhumki Assignment

The document is a lab report from Sylhet Engineering College for a Digital Signal Processing course, detailing the submission by Jhumki Barmon and Tanjim Akter Anisha Payel. It includes calculations for polynomial convolution, impulse response of a causal system, and designs for digital oscillation and filters. The report provides MATLAB code, output results, and discussions on system stability and characteristics.
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)
12 views37 pages

Jhumki Assignment

The document is a lab report from Sylhet Engineering College for a Digital Signal Processing course, detailing the submission by Jhumki Barmon and Tanjim Akter Anisha Payel. It includes calculations for polynomial convolution, impulse response of a causal system, and designs for digital oscillation and filters. The report provides MATLAB code, output results, and discussions on system stability and characteristics.
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/ 37

Sylhet Engineering College

Lab Report 03
Course Title: Digital Signal Processing Sessional

Course Code: CSE 806


Submission Date: 27/01/2025

Submitted By: Submitted To:


Jhumki BARMON Dr. Md Mohsinur Rahman Adnan
Reg. No: 2019331553 Assistant professor
Group Partner: Department of EEE
TANJIM AKTER ANISHA PAYEL Shahjalal University of Science and
Reg. No: 2019331564 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 of H(z)');
xlabel('Real Part');
ylabel('Imaginary Part');
grid on;

% Define the input sequences


x_impulse = [1, zeros(1, 9)]; % Impulse input (delta(n))
x_step = ones(1, 10); % Unit step input (u(n))

% Compute system responses


y_impulse = filter(numerator, denominator, x_impulse); % Response to impulse input
y_step = filter(numerator, denominator, x_step); % Response to step input

% Display the responses


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

fprintf('Response to Unit Step Input:\n');


disp(y_step);

% Plot the impulse response


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

% Plot the step response


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

Output:
Discussion:

 Transfer Function:
The transfer function of the system is H(z)=z/(z−1)H(z) = z / (z - 1)H(z)=z/(z−1), where the
numerator defines a zero at the origin (z=0z = 0z=0), and the denominator defines a pole at z=1z
= 1z=1. The pole at z=1z = 1z=1 lies on the boundary of the unit circle, indicating that the
system is unstable. This transfer function represents a system where the output grows unbounded
in response to certain inputs.

 Pole-Zero Plot:
The pole-zero plot visually represents the dynamics of the system in the z-domain. It shows a
pole at z=1z = 1z=1 and a zero at the origin (z=0z = 0z=0). The pole at z=1z = 1z=1 indicates
that the system is unstable, as it leads to unbounded growth in the output. The zero at the origin
affects how the system attenuates or amplifies signals at different frequencies, influencing the
system's frequency response.

 Impulse Response:
The response to a unit impulse input (δ(n)\delta(n)δ(n)) is calculated using the transfer function.
Due to the pole at z=1z = 1z=1, the impulse response grows unbounded, reflecting the instability
of the system. The system repeatedly accumulates the input value instead of settling to a steady
state. This behavior is clearly visible in the plotted impulse response, where the output increases
without bound over time.

 Step Response:
The response to a unit step input (u(n)u(n)u(n)) is also computed. Similar to the impulse
response, the step response exhibits unbounded growth due to the unstable pole at z=1z = 1z=1.
The plotted step response shows a steadily increasing output, consistent with the system's
theoretical behavior. This unbounded growth further highlights the instability caused by the
pole's location.

 System Behavior:
The defining characteristic of this system is its instability, which stems from the pole at z=1z =
1z=1. Both the impulse and step responses grow without bound, making the system unsuitable
for practical applications. To address this instability, techniques such as pole shifting or
stabilization would be required to modify the system dynamics and ensure bounded responses to
input signals.

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); % Plot the poles and zeros
grid on; % Add a grid for better visualization
title('Pole-Zero Plot of H(z)');
xlabel('Re (Real Part)');
ylabel('Im (Imaginary Part)');

% Impulse response (unit sample response)


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

% Plot the impulse response


figure;
stem(n, h, 'filled', 'LineWidth', 1.5); % Use stem plot for discrete signals
grid on; % Add grid for better readability
title('Impulse Response h(n)');
xlabel('n (Time Index)');
ylabel('h(n) (Amplitude)');

% Theoretical verification (System function H(z))


disp('System Function H(z):');
disp('(z + 1/3) / (z - 1/2)');
disp('Unit Sample Response h(n):');
disp('(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:

 System Definition and Transfer Function:


The transfer function H(z)H(z)H(z) defines the system's response to input signals in the z-
domain. The numerator [1,1/3][1, 1/3][1,1/3] specifies a zero at z=−1/3z = -1/3z=−1/3, which
influences the system's frequency response. The denominator [1,−1/2][1, -1/2][1,−1/2] specifies
a pole at z=1/2z = 1/2z=1/2, and since this pole lies within the unit circle, the system is
confirmed to be stable.

 Pole-Zero Plot:
The pole-zero plot graphically represents the dynamics of the system in the z-domain. The pole
located at z=1/2z = 1/2z=1/2 indicates that the system's response decays exponentially with a
factor of (1/2)n(1/2)^n(1/2)n. The zero at z=−1/3z = -1/3z=−1/3 alters the system's gain and
spectral behavior. This visualization aids in understanding the relationship between the pole,
zero, and system stability.

 Impulse Response:
The system's impulse response, h(n)h(n)h(n), is computed analytically as h(n)=(4/3)(1/2)nh(n) =
(4/3)(1/2)^nh(n)=(4/3)(1/2)n for n≥0n \geq 0n≥0. This response reflects the system's reaction to a
unit impulse input and demonstrates exponential decay, dictated by the pole at z=1/2z =
1/2z=1/2. The diminishing response over time further confirms the system's stability.

 System Verification:
The transfer function and impulse response were verified analytically. The transfer function is
H(z)=(z+1/3)/(z−1/2)H(z) = (z + 1/3) / (z - 1/2)H(z)=(z+1/3)/(z−1/2), while the impulse response
is h(n)=(4/3)(1/2)nu(n)h(n) = (4/3)(1/2)^n u(n)h(n)=(4/3)(1/2)nu(n). This ensures consistency
between theoretical calculations and system implementation.

 System Behavior:
The system operates as a simple low-pass filter. The pole at z=1/2z = 1/2z=1/2 determines the
exponential decay rate and introduces a smoothing effect, while the zero at z=−1/3z = -1/3z=−1/3
adjusts the frequency response, slightly enhancing or attenuating specific frequency components.
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 and numerator represent the transfer function H(z)
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);

% Find the zeros of the system (roots of the numerator)


zeros = roots(numerator);

% Display the poles and zeros


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

% Plot the poles and zeros using zplane


figure;
zplane(numerator, denominator); % Visualize poles and zeros
grid on; % Add a grid for clarity
title('Pole-Zero Plot of H(z)');
xlabel('Re (Real Part)');
ylabel('Im (Imaginary Part)');
% Compute Region of Convergence (ROC) for different cases
roc_causal = max(abs(poles)); % ROC for causal system: |z| > max(abs(poles))
roc_anticausal = min(abs(poles)); % ROC for anticausal system: |z| <
min(abs(poles))
roc_noncausal = [min(abs(poles)), max(abs(poles))]; % ROC for noncausal system:
min < |z| < max

% Display ROC for causal, anticausal, and noncausal systems


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
% A system is stable if all poles are inside the unit circle (|pole| < 1)
is_stable = all(abs(poles) < 1);
if is_stable
disp('The system is stable: All poles are inside the unit circle.');
else
disp('The system is unstable: At least one pole is outside the unit circle.');
end

% Additional Visualization: Annotate Pole-Zero Plot


hold on; % Keep the plot active for annotation
for i = 1:length(poles)
text(real(poles(i)), imag(poles(i)), ' Pole', 'VerticalAlignment', 'bottom',
'HorizontalAlignment', 'right');
end
for i = 1:length(zeros)
text(real(zeros(i)), imag(zeros(i)), ' Zero', 'VerticalAlignment', 'bottom',
'HorizontalAlignment', 'left');
end
hold off;

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:

Here’s your content rewritten in a point-by-point paragraph style:

1. System Representation:
The transfer function H(z)H(z) is defined by its numerator and denominator coefficients.
The numerator specifies the zeros of the system, while the denominator determines the
poles. These poles and zeros play a crucial role in shaping the system’s dynamic behavior
and frequency response.
2. Pole-Zero Analysis:
The poles of the system are calculated as the roots of the denominator polynomial, while
the zeros are obtained from the roots of the numerator. A pole-zero plot is used to
visualize these components in the z-domain. Poles located close to the unit circle
represent signals that decay slowly, while poles outside the unit circle indicate instability.
3. Region of Convergence (ROC):
The ROC defines the range of zz-values where the system’s Z-transform converges. For a
causal system, the ROC lies outside the outermost pole (∣z∣>max(poles)|z| > \
text{max(poles)}). For an anticausal system, the ROC is inside the innermost pole
(∣z∣<min(poles)|z| < \text{min(poles)}). A noncausal system has an ROC between the
poles (min(poles)<∣z∣<max(poles)\text{min(poles)} < |z| < \text{max(poles)}).
4. System Stability:
The stability of the system is determined by the location of its poles. If all poles lie
strictly inside the unit circle (∣z∣<1|z| < 1), the system is stable, and its impulse response
converges. If any pole lies on or outside the unit circle, the system becomes unstable. In
this case, a pole at z=3z = 3 is outside the unit circle, indicating that the system is
unstable.

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]; % Coefficients of the numerator (z^2)
denominator_causal = [1 -0.5 1]; % Coefficients of the denominator (z^2 - 0.5z + 1)

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


numerator_anticausal = [1 0 0]; % Coefficients of the numerator (z^2)
denominator_anticausal = [1 -2.5 0.5]; % Coefficients of the denominator (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 functions
disp('Causal System Transfer Function H(z):');
disp(H_causal);

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


disp(H_anticausal);

% Frequency Response Analysis:


% Plot the frequency response (magnitude and phase) for both systems
figure;

% Causal System Frequency Response


subplot(2, 1, 1);
bode(H_causal); % Plot Bode plot for causal system
grid on; % Add grid for better visualization
title('Causal System Frequency Response');

% Anticausal System Frequency Response


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

% Additional Analysis: Pole-Zero Plot for Both Systems


% Plot the poles and zeros for causal and anticausal systems
figure;

subplot(1, 2, 1);
zplane(numerator_causal, denominator_causal); % Pole-zero plot for causal system
grid on; % Add grid for clarity
title('Causal System: Pole-Zero Plot');
xlabel('Re (Real Part)');
ylabel('Im (Imaginary Part)');

subplot(1, 2, 2);
zplane(numerator_anticausal, denominator_anticausal); % Pole-zero plot for
anticausal system
grid on; % Add grid for clarity
title('Anticausal System: Pole-Zero Plot');
xlabel('Re (Real Part)');
ylabel('Im (Imaginary Part)');
Discussion:

 System Definitions:
The two systems analyzed are a causal system and an anticausal system. The causal system has
its transfer function H(z)H(z)H(z) defined such that the poles are positioned to ensure causality.
This means the system's output depends only on the current and past input values. In contrast, the
anticausal system has its poles configured to emphasize future input values. While anticausality
is less common in practical applications, it is relevant in theoretical studies and specific control
or predictive scenarios.

 Transfer Function Representation:


Both systems are described using their numerator and denominator coefficients, which determine
their behavior in the zzz-domain. For the causal system, the poles are positioned closer to the
unit circle, ensuring stability for a causal response. The anticausal system, however, places its
poles further away from the unit circle, leading to a different type of response that emphasizes
future inputs and may potentially affect stability.

 Frequency Response Analysis:


The frequency responses of both systems are analyzed and visualized using Bode plots. The
magnitude response illustrates how each system amplifies or attenuates signals at different
frequencies, while the phase response reveals the phase shift introduced at these frequencies. For
the causal system, the frequency response indicates stable and predictable behavior consistent
with a causally configured system. In contrast, the anticausal system exhibits a response that
reflects its dependency on future input values, which can result in irregular behavior depending
on the pole placement.

 Comparison of Causal and Anticausal Systems:


The primary differences between the causal and anticausal systems lie in their pole
configurations and resulting behavior. The poles in the causal system are placed to ensure
stability and proper causal operation, while the anticausal system’s poles are positioned to
emphasize future inputs. This difference affects their frequency responses, with the causal
system demonstrating a stable and predictable response, whereas the anticausal system may
display unconventional or less stable characteristics based on its configuration.

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:

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);

% Ensure the leading coefficient is 1 (normalize if necessary)


if denominator(1) ~= 1
denominator = denominator / denominator(1);
end

% Initializing the Schur-Cohn array


S = zeros(n, n);

% Step 1: First row (denominator coefficients)


S(1, 1:n) = denominator;

% Step 2: Construct the Schur-Cohn array recursively


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

% Display the Schur-Cohn array for debugging and analysis


disp('Schur-Cohn Array:');
disp(S(1:n, 1:n)); % Show only the relevant part of the array

% Step 3: Check the stability criterion (all values in the last row must be positive)
if all(abs(S(n, 1:(n-1))) < 1) && abs(S(n, end)) < 1
disp('The system is stable: All roots are inside the unit circle.');
isStable = 1; % Stable system
else
disp('The system is unstable: At least one root lies outside the unit circle.');
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:

 Input and Setup:


The input to the Schur-Cohn stability test is the set of coefficients of the denominator polynomial
of the system's transfer function. These coefficients represent the system's poles in the z-domain.
The function determines stability by recursively constructing a Schur-Cohn array, which
analyzes the behavior of the system based on the pole locations.

 Schur-Cohn Array Construction:


The Schur-Cohn array is constructed starting with the denominator polynomial coefficients as
the first row. Each subsequent row is calculated recursively using a defined relation that
incorporates both the current and previous row elements. This recursive process continues until
the array is fully populated, providing the necessary data to assess the system's stability.

 Stability Criterion:
The system is considered stable if all entries in the final row of the Schur-Cohn array are non-
negative. This condition ensures that all poles of the system lie strictly within the unit circle
(∣z∣<1|z| < 1∣z∣<1), confirming the system's stability and its ability to produce bounded outputs for
bounded inputs.

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', 'LineWidth', 1.5);
title('Impulse Response h(n) of the System');
xlabel('n');
ylabel('h(n)');
grid on;

% Cascaded system: Adding another pole


z3 = 0.5; % Pole from the second system

% Define transfer function of the cascaded system


numerator1 = [1 0 0]; % Numerator of the first system
denominator1 = [1 -z1 z2]; % Denominator of the first system
numerator2 = [1]; % Numerator of the second system
denominator2 = [1 -z3]; % Denominator of the second system

% Combine the cascaded system


numerator_cascaded = conv(numerator1, numerator2); % Combined numerator
denominator_cascaded = conv(denominator1, denominator2); % Combined
denominator

% Plot the poles of the cascaded system


figure;
zplane(numerator_cascaded, denominator_cascaded); % Pole-zero plot for the
cascaded system
title('Pole-Zero Plot of the Cascaded System');
xlabel('Re (Real Part)');
ylabel('Im (Imaginary Part)');
grid on;

% Highlight individual systems


hold on;
zplane(numerator1, denominator1); % Poles and zeros of the first system
zplane(numerator2, denominator2); % Poles and zeros of the second system
legend('Cascaded System', 'First System', 'Second System');
hold off;

Output:

Discussion:

 Impulse Response:
The impulse response of the system reveals its stability through the exponential growth or decay
of the response. This behavior is determined by the magnitudes of the poles. If the poles lie
outside the unit circle, the response grows unbounded, indicating instability. The coefficients
AAA and BBB affect only the amplitude of the response, not its stability, allowing for
adjustments in scaling without altering the underlying behavior.

 Effect of Cascading:
When cascading the system with an additional pole (z3z_3z3) from a second system, the
dynamics of the overall system are influenced. The location of z3z_3z3 plays a critical role in the
stability of the cascaded system. If z3z_3z3 is within the unit circle, it contributes to maintaining
stability. However, if it lies outside the unit circle, it can destabilize the system, regardless of the
original system's poles.

 Visualization:
The pole-zero plot serves as a vital tool for analyzing the system’s behavior. It provides a
graphical representation of the poles and zeros in the z-domain, offering insights into stability
and the potential for resonance. By observing the location of the poles and zeros relative to the
unit circle, one can assess the system's stability and dynamic characteristics effectively.

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); % Generate sine wave
awgn_noise = sqrt(noise_power) * randn(size(t)); % Additive white Gaussian noise
input_signal = sine_wave + awgn_noise; % Combined noisy signal

% 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); % Filter the 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 around 0

% Plot results
figure;

% Plot input signal


subplot(5, 1, 1);
plot(t, input_signal, 'LineWidth', 1.5);
title('Input Signal (Sine Wave + AWGN)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

% Plot LPF output


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

% Plot Zero-Crossing Detector (ZCD) output


subplot(5, 1, 3);
stairs(t, ZCD_output, 'LineWidth', 1.5);
title('Zero-Crossing Detector Output');
xlabel('Time (s)');
ylabel('Binary Output');
grid on;
% Plot edge detector output
subplot(5, 1, 4);
plot(t, edge_detector_output, 'LineWidth', 1.5);
title('Edge Detector Output');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

% Plot triangular wave generator output


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

% Adjust plot layout


sgtitle('System Responses');

Output:
Discussion:
 Input Signal:
The input signal consists of a sine wave combined with additive white Gaussian noise (AWGN).
This simulates real-world scenarios where noise is present alongside the desired signal, making it
a practical example of signal processing challenges.

 Low-Pass Filter (LPF):


The low-pass filter serves to smooth the input signal by removing higher frequency noise
components. This filtering process allows the underlying sine wave to become more visible and
reduces the impact of noise, providing a cleaner signal for subsequent processing.

 Zero-Crossing Detector (ZCD):


The ZCD detects zero crossings in the filtered signal and outputs a binary representation of the
signal's polarity. It converts the continuous waveform into a binary form, simplifying the signal
while highlighting changes in sign.

 Edge Detector:
The edge detector processes the binary output from the ZCD to identify transitions, such as
changes from positive to negative or vice versa. This operation emphasizes key points in the
signal where significant changes occur, such as peaks or troughs.

 Triangular Wave Generator:


The triangular wave generator integrates the output of the edge detector using cumulative
summation. This process forms a continuous triangular waveform that represents the discrete
changes detected by the edge detector. The waveform is further adjusted to center it around zero
for symmetry.

 Visualization:
The plots at each stage of the process provide insights into how the signal evolves from a noisy
sine wave to a clean triangular waveform. Each stage highlights a specific aspect of signal
processing, from noise reduction to feature extraction and waveform synthesis.

 Implications:
This process demonstrates the effectiveness of digital signal processing techniques in handling
noisy signals. By transforming noisy input into a meaningful triangular waveform, these
techniques provide valuable data that can be used 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]; % Coefficients of the polynomial D(z)

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


poles = roots(D_coeffs);

% Check magnitudes of the poles to determine stability


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

% Display the 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

% Enhanced visualization of the poles on the z-plane


figure;
zplane([], poles); % No zeros are defined, only poles
grid on; % Add grid for better visualization
title('Poles of the System on the z-plane');
xlabel('Real Part');
ylabel('Imaginary Part');

% Annotate the stability information


hold on;
for k = 1:length(poles)
if abs(poles(k)) < 1
text(real(poles(k)), imag(poles(k)), ' Stable Pole', 'VerticalAlignment', 'bottom',
'HorizontalAlignment', 'left');
else
text(real(poles(k)), imag(poles(k)), ' Unstable Pole', 'VerticalAlignment',
'bottom', 'HorizontalAlignment', 'left');
end
end
hold off;

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:

 Definition of Poles:
The poles of the system are calculated as the roots of the denominator polynomial
D(z)=[1,−1/2,1/2,0,−3/4,1,1/8,−9/13]D(z) = [1, -1/2, 1/2, 0, -3/4, 1, 1/8, -
9/13]D(z)=[1,−1/2,1/2,0,−3/4,1,1/8,−9/13]. These roots are fundamental in determining the
system's behavior and response in the z-domain.

 Stability Check:
The stability of the system is assessed by checking whether all the poles lie within the unit circle.
A system is considered stable if the magnitudes of all poles are strictly less than 1. Poles outside
or on the boundary of the unit circle indicate instability.

 Poles and Analysis:


The roots of the polynomial D(z)D(z)D(z) represent the system’s poles, which play a critical role
in determining the system's dynamic response. The location of these poles directly affects the
system’s stability, transient behavior, and frequency response.

 Stability Assessment:
By evaluating the magnitudes of the poles, the stability of the system is determined. If all poles
are inside the unit circle, the system is stable and capable of producing bounded outputs for
bounded inputs. If any pole lies outside the unit circle, the system becomes unstable, resulting in
unbounded responses.

 Z-Plane Plot Visualization:


The z-plane plot graphically displays the real and imaginary components of the poles. This
visualization provides a clear representation of their locations relative to the unit circle, helping
to easily identify whether the system is stable or unstable. Stable poles are shown within the unit
circle, while unstable poles are displayed outside it.

You might also like