Jhumki Assignment
Jhumki Assignment
Lab Report 03
Course Title: Digital Signal Processing Sessional
Code:
fprintf('Coefficients of X2(z):\n');
disp(coeff_X2);
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:
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.
Code:
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.
Part – B
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
Output:
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.
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
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)
Code:
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:
Output:
System Function H(z) = (z + 1/3) / (z - 1/2)
Unit Sample Response h(n) = (4/3) * (1/2)^n u(n)
Discussion:
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.
Code:
% 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
Output:
Poles of H(z):
3.0000
0.5000
Discussion:
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
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.
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:
% 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
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.
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:
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.
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
% Plot results
figure;
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.
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.
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.
Code:
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
Output:
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.
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.