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

Lab 5 Group4

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lab 5 Group4

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Course:CPE416 Section: CPE41S1

Name/s: Justimbaste, Allen Hendrix G. Date Performed:10/14/2024


Aaron Kyle Ocariza Date Submitted:10/14/2024
Edjie Sangalang Instructor: Engr. Marte Nipas
Joice Ann Eisley Viernes
Gabriel Edmund Vinas
Laboratory Activity No. 5
Delta Function and Impulse Response

1. Objective(s):
● To understand the delta function and its role in Digital Signal Processing (DSP).
● To analyze the impulse response of discrete-time systems using MATLAB.
● To explore the relationship between input signals (delta function) and system output (impulse
response).
● To develop hands-on experience in using MATLAB for simulating DSP operations.

2. Intended Learning Outcomes (ILOs):

At the end of the activity student shall able to:

● Define and generate the delta function in MATLAB.


● Simulate the impulse response of a discrete-time system.
● Analyze system behavior by examining its impulse response.

3. Materials

● PC with Internet connection


● Matlab

4. Discussion

The delta function, also known as the Dirac delta or unit impulse, plays a crucial role in signal
processing. It is used to characterize the impulse response of linear time-invariant (LTI) systems, which
provides insight into the system's behavior and its effect on various input signals. The impulse response
is essentially the output when a delta function is applied to the system. By studying the impulse
response, we can predict the output for any arbitrary input signal due to the convolution operation.

● Delta Function (δ[n])- A discrete signal that is zero everywhere except at n = 0, where its value
is 1.
● Impulse Response (h[n])- The output of a system when the delta function is applied as input.

1
5. Procedures

1. Setup MATLAB Environment


● Launch MATLAB and create a new script file named delta_impulse_response.m.

2. Generating the Delta Function


● Define a delta function in MATLAB using the following code

n = -10:10; % Define a time vector

delta = (n == 0); % Create a delta function

stem(n, delta); % Plot the delta function

title('Delta Function');

xlabel('n'); ylabel('Amplitude');

3. Define a Discrete-Time System


● Consider a simple system characterized by the difference equation:

y[n]=0.5y[n−1]+x[n]

● Define the system in MATLAB

2
a = [1, -0.5]; % Coefficients of y[n]

b = [1]; % Coefficients of x[n]

4. Compute the Impulse Response


● Use MATLAB’s impz() function to compute and visualize the system's impulse
response

[h, n] = impz(b, a, 20); % Calculate impulse response

stem(n, h); % Plot the impulse response

title('Impulse Response');

xlabel('n'); ylabel('h[n]');

3
5. Analyze the Results
● Observe how the system responds to the delta function. Discuss how the impulse
response behaves over time.

6. Experiment with Different Systems


● Modify the system coefficients (in a and b) and repeat steps 3 and 4. Observe how
changes in system parameters affect the impulse response.

6. Data and Results

● Record the MATLAB plots (delta function and impulse response) and explain the effect of
varying the coefficients of inputs and outputs.

4
● Tabulate the data and explain the results.

Key differences in these two systems are obtained based on their impulse responses and the amplitude
of outputs. The rapid response of the first leads one to think that it could have wider opportunities for
general instability, however its gradual behavior is well suited as output in a process where features
require stable behavior. Altering the output of impulse response changes where in the plot because that
is what forces it to a new value then time goes on.

6. Supplemental Activity

5
1. Modify the delta function to shift its position in time. Plot and compare multiple delta functions
n = -10:10;
delta1 = (n == 0); % Delta function at n=0
delta2 = (n == -3); % Delta function shifted to n=-3
delta3 = (n == 5); % Delta function shifted to n=5

% Define the time vector

n = -10:10;

% Define delta functions at different time shifts

delta1 = (n == 0); % Delta function at n=0

delta2 = (n == -3); % Delta function shifted to n=-3

delta3 = (n == 5); % Delta function shifted to n=5

% Plot all three delta functions on the same figure

figure;

% Subplot 1: Delta function at n=0

subplot(3, 1, 1);

stem(n, delta1, 'r', 'DisplayName', 'Delta at n=0');

6
title('Delta Function at n=0');

xlabel('n'); ylabel('Amplitude');

% Subplot 2: Delta function at n=-3

subplot(3, 1, 2);

stem(n, delta2, 'g', 'DisplayName', 'Delta at n=-3');

title('Delta Function at n=-3');

xlabel('n'); ylabel('Amplitude');

% Subplot 3: Delta function at n=5

subplot(3, 1, 3);

stem(n, delta3, 'b', 'DisplayName', 'Delta at n=5');

title('Delta Function at n=5');

xlabel('n'); ylabel('Amplitude');

% Overall title and labels for the comparison plot

sgtitle('Comparison of Delta Functions at Different Time Shifts');

2. Find the value and plot impulse response of the following difference equations and answer the
questions that follow.
a. 3-point moving average filter: y(n)= [x(n)+x(n−1)+x(n−2)]/3

7
How would increasing or decreasing the window size (number of points) affect the
impulse response? Support your answer.
Increasing the window size, that is the number of points considered in an average,
increases width and smoothness of the impulse response, and therefore it contributes to
more high frequency components attenuation. A smaller window size will make the
response narrower with less smoothing.

b. simple high-pass filter: y[n]=x[n]−αx[n−1]

8
How does the value of α affect the amplitude of the impulse response? Support your
answer.
The value of alpha (α) greatly influences the strength of an initial high-pass filter. A
higher value of α offers a smoother output in filtering, which tends to weaken the
amplitude of the impulse response. With such characteristics, this is associated with
quick decay in output and requires significant changes in input to cause significant
changes in output. A smaller α, however, will result in a more effective filtered result,
reducing the amplitude of the impulse response. This is due to the output's gradual
decrease and becoming more responsive to small changes in the input.
c. second-order system (resonator) : y[n]=2cos(ω0 )y[n−1]−y[n−2]+x[n] , ω0=pi/4

9
What is the primary frequency of oscillation observed in the impulse response?
We look in the plot at the impulse response in order to determine the behavior of a
second-order resonator. It has periodic oscillations and, we can guess in the plot by
counting the number of samples per cycle, the primary frequency of oscillation. Since
we believe that the signal completes one cycle roughly every 4 to 5 samples we have a
normalized frequency of about:. It is equivalent to the natural frequency of the resonator,
that is, the rate with which the oscillation system moves.
How does changing ω0 affect the resonator’s behavior? Support your answer.
If ω0​changes, then it does not only change the behavior of the resonator but also
regulates the oscillations to be faster or slower with respect to growing values. he more
values of ω0​mean that more cycles in oscillations will be completed under the same
number of samples. Since an increase in the angle argument to any of the oscillations
above corresponds to a shift in time, if ω0 decreases, then the rates of oscillation
decrease, and fewer cycles will be seen between the same range of samples.
Essentially, changing ω0 merely changes the oscillation frequency; higher values of ω0
result in more rapid oscillations, while lower values lead to more lengthy, spread-out
oscillations. That is the response of the resonator to a change in frequency.

7. Conclusion:

What conclusion can you make based on the activity?

10
This activity shows that the delta function helps us understand how systems react to different signals.
The impulse response reveals how the system behaves on fast input. Changing the settings of the system
changes the way in which the response looks. For instance, applying more points in a filter smooths the
response and adjustment of parameters changes the strength of the effects. In oscillating systems,
changing the frequency of the system made them oscillate either faster or slower. This helped us
understand how systems act for different signals.

11

You might also like