dsp1
dsp1
Objective: To Find out the impulse and step response of the systems described as
Theory:
• The impulse response of a system is the output of the system when the input is an impulse, δ(t), and
all initial conditions are zero.
• The step response of a system is the output of the system when the input is a step, H(t), and all
initial conditions are zero.
Matlab programs:
1st question
N = 40; % Define the number of samples for the impulse and step responses
num = [1 0 0]; % Numerator coefficients of the transfer function (z^2 term only)
[h, t] = impz(num, den, N); % h = impulse response, t = time index vector (0 to N-1)
sys = tf(num, den, -1); % 'tf' creates the transfer function; -1 means discrete with
unspecified sample time
2nd question
N = 40; % Define the number of samples for impulse and step responses
[h, t] = impz(num, den, N); % h = impulse response, t = sample indices (from 0 to N-1)
stem(t, h); % Use stem plot for the discrete impulse response
[y, t_step] = step(sys, N); % Compute step response y over N samples with time index t_step
stem(t_step, y); % Use stem plot for the discrete step response
Conclusion: The impulse and step responses of discrete systems provide essential insights into their behavior and
stability. The impulse response shows how the system reacts to a single input, while the step response reveals how it
behaves over time. Together, they help determine whether the system is stable, causal, and how it responds to
different inputs—making them crucial tools in system analysis and design.
Experiment 2:
Theory:
Sampling: Is the process of converting a continuous time signal into a discrete time signal. It is the first step in
conversion from analog signal to digital signal.
Sampling theorem: Sampling theorem states that “Exact reconstruction of a continuous time base-band signal from
its samples is possible, if the signal is band-limited and the sampling frequency is greater than twice the signal
bandwidth” i.e. fs > 2W, where W is the signal bandwidth.
Nyquist Rate Sampling: The Nyquist rate is the minimum sampling rate required to avoid aliasing, equal to the highest
modulating frequency contained within the signal. In other words, Nyquist rate is equal to two-sided bandwidth of
the signal (Upper and lower sidebands). To avoid aliasing, the sampling rate must exceed the Nyquist rate. i.e. fs > fn.
Matlab program:
clc;
ylabel('fs=100');
ylabel('fs=4');
xlabel('seconds');
ylabel('fs=10');
xlabel('seconds');
ylabel('fs=60');
Conclusion:
The experiment verifies the Sampling Theorem by demonstrating that a continuous-time signal can be accurately
reconstructed from its samples only when the sampling frequency is greater than twice the signal bandwidth. If the
sampling frequency is below this threshold, aliasing occurs, making reconstruction impossible. This confirms the
necessity of sampling at or above the Nyquist rate to ensure faithful reproduction of the original analog signal.
Experiment 2:
Obj:
Programs:
N = input('Enter Number of Samples: '); % Prompt the user to enter number of samples on one side
x = [zeros(1, N), 1, zeros(1, N)]; % Create unit impulse signal (1 at n=0, zeros elsewhere)
Output:-
N = input('Enter Number of Samples: '); % Prompt user to enter number of samples on each side
x = [zeros(1, N), 1, ones(1, N)]; % Create unit step signal: 0 for n<0, 1 at n=0, and 1 for n>0
stem(n, x); % Plot the unit step signal using a stem plot
Output:-
Number of Samples : 6
3. Unit ramp signal
N = input('Enter Number of Samples: '); % Prompt user to enter number of ramp samples
stem(n, x); % Plot the unit ramp signal using a stem plot
Output:-
Amplitude: 20
4. Exponential decaying signal
N = input('Enter Number of Samples: '); % Prompt user to enter the maximum time value
output
N = input('Enter Number of Samples: '); % Prompt the user to enter number of samples
a = 0.5; % Base value (0 < a < 1 for exponential growth when raised to -n)
stem(n, x); % Plot the signal using a stem plot (discrete signal)
Output:-
Number of Samaples : 6
6. Cosine signal
xlabel ('Time') ;
ylabel ('Amplitude');
Output:-
COSINE SIGNAL
7. Sine signal
n= 0:0. 1:N
x=sin( n) ;
stem (n,x);
Output:-
SINE SIGNAL
clc;
close all;
N=256;
plot(t,y3,'k');
Output:
9.Generation of amplitude modulated signal
Amplitude modulation is a process by which the wave signal is transmitted by modulating the amplitude of the
signal. It is often called AM and is commonly used in transmitting a piece of information through a radio carrier wave.
Amplitude modulation is mostly used in the form of electronic communication.
Program:
clc;
t = 0:0.001:5; %time.
pmo = pmo/Ac;
subplot(4,1,1);
plot(t, msg);
xlabel('time (sec)');
ylabel('amplitude');
gridon;
subplot(4,1,2);
plot(t, carrier);
title("CARRIER SIGNAL (TIME DOMAIN)");
xlabel('time (sec)');
ylabel('amplitude');
gridon;
subplot(4,1,3);
plot(t, dsb_sc);
xlabel('time (sec)');
ylabel('amplitude');
gridon;
subplot(4,1,4);
plot(t, msg_r);
xlabel('time (sec)');
ylabel('amplitude');
gridon;
output:
10.Frequency modulated signal using.
Frequency modulation is a technique or a process of encoding information on a particular signal (analogue or digital)
by varying the carrier wave frequency in accordance with the frequency of the modulating signal.
Program:
fm=25;
fc=400;
B=10
t=0:0.0001:0.5;
m=cos(2*pi*fm*t);
subplot(3,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
c=cos(2*pi*fc*t);
subplot(3,1,2);
plot(t,c);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;
y=cos(2*pi*fc*t+(B*sin(2*pi*fm*t)));
subplot(3,1,3);
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('FM Signal');
grid on;
output/;
Conclusion:
In this experiment, various basic discrete-time signals such as the unit impulse, unit step, unit ramp, and
exponentially decaying signals were generated and visualized using MATLAB. Each signal was defined mathematically
and implemented through vector operations and stem plots for discrete representation. The practical
implementation of these signals helped in understanding their characteristics and behavior in time domain. This
experiment reinforced foundational concepts of signal processing and provided hands-on experience in MATLAB
programming for signal analysis.
Experiment: 4
Theory :
Correlation: Correlation determines the degree of similarity between two signals. If the signals are identical, then the
correlation coefficient is 1; if they are totally different, the correlation coefficient is 0, and if they are identical except
that the phase is shifted by exactly 1800(i.e. mirrored), then the correlation coefficient is -1.
4.1. program
stem(x);
ylabel('Amplitude');
xlabel('(a) n');
title('Sequence x[n]');
stem(h);
ylabel('Amplitude');
xlabel('(b) n');
title('Sequence h[n]');
ylabel('Amplitude');
xlabel('(c) n');
title('Cross-Correlation Output');
% Plotting
figure;
stem(x);
ylabel('Amplitude →');
xlabel('n →');
ylabel('Amplitude →');
xlabel('Lag →');
title('Auto-Correlation Sequence');
[1 2 4 3]
Output:
Conclusion
Auto-correlation helps identify repeating patterns within a signal, while cross-correlation measures the similarity
between two signals, often used to detect time delays or alignment. Both are essential tools in signal analysis, with
broad applications in communications, control, and pattern recognition.
Experiment 5:
Program:
a = input('Enter the input sequence: '); % User input for the sequence
subplot(2,2,1);
stem(n, a);
ylabel('Amplitude');
title('Input Sequence');
% Compute the FFT of the input sequence
x = fft(a, m);
subplot(2,2,2);
stem(k, abs(x));
ylabel('Magnitude');
subplot(2,2,3);
stem(k, angle(x));
ylabel('Phase (radians)');
Output:-
Program:
m = fft(x1, n);
disp(m);
N = 0:1:n-1;
% Plot the magnitude spectrum of the DFT
subplot(2,2,1);
stem(N, abs(m));
xlabel('Length');
ylabel('Magnitude of X(k)');
title('Magnitude Spectrum');
an = angle(m);
subplot(2,2,2);
stem(N, an);
xlabel('Length');
ylabel('Phase of X(k)');
title('Phase Spectrum');
Output:-
Column 4
1.0 + 1.0000i
Conclusion
The Discrete Fourier Transform (DFT) is a powerful tool for analyzing the frequency content of discrete signals,
but it is computationally intensive. The Fast Fourier Transform (FFT) efficiently computes the DFT, significantly
reducing processing time and making real-time signal analysis practical. Understanding both methods is
essential for applications in digital signal processing, communications, and image analysis.