DSP Lab Report
DSP Lab Report
DSP Lab Report
Submitted To
Abu Zahed Chowdhury
Associate Professor
Department of Electrical & Electronic Engineering
University of Chittagong
Submitted By
Name: Md Arman Kabir
ID: 20702061
Department of Electrical & Electronic Engineering
University of Chittagong
Objective:
To write the MATLAB code for the generation of continuous time signal.
Apparatus required:
Hardware: Personal computer.
Software: Matlab 2014a or above
Theory:
Continuous Time Signals:
Continuous-time signals are defined along a continuum of time and are thus, represented by
a continuous independent variable. Continuous-time signals are often referred to as analog
signals. This type of signal shows continuity both in amplitude and time. These will have
values at each instant of time. Sine and cosine functions are the best example of Continuous
time signal.
The signal shown above is an example of continuous time signal because we can get value of
signal at each instant of time.
Mathematical Representation:
A continuous-time signal is mathematically represented as a function of time, denoted by
x(t), where "t" is the independent variable representing time. The function x(t) describes the
amplitude of the signal at each instant in time "t." The function can be any mathematical
expression or formula that relates the time variable to the signal's amplitude.
For example, a simple continuous-time sinusoidal signal can be represented as:
x(t) = A * sin(ωt + φ)
where A is the amplitude, ω is the angular frequency, and φ is the phase angle of the
sinusoidal signal.
Mathematical Representation:
A discrete-time signal is mathematically represented as a sequence of numbers, denoted by
x[n], where "n" is the discrete-time index. Each value of x[n] corresponds to the amplitude of
the signal at a specific time instant "n." For example, a simple discrete-time sequence
representing a unit impulse can be written as: x[n] = δ[n] where δ[n] is the Kronecker delta
function, which is equal to 1 when "n" is zero and 0 otherwise.
Procedure:
Start the MATLAB program.
Write the program.
Compile and Run the program.
Define the time vector (t) and sampling rate (Fs)
Choose the type of continuous-time signal to generate (e.g., sine, cosine, square,etc.)
Determine the signal parameters (frequency, amplitude, phase, etc.)
Generate the continuous-time signal using MATLAB functions (e.g., sin, cos, etc.)
Plot the continuous-time signal
Optional: Add labels, titles, and legends to the plot
Display the plot
End
FlowChart:
Program Code:
Continuous Time Signal :
clear all
%Program for Exponential Growing signal
t=0:0.1:10;
%Program for Sine Wave y=exp(t);
t= 0 : 0.01 : 6 ; subplot(4,2,5)
y= sin(2*pi*t); plot(t,y,"r"); grid on
subplot(4,2,1) ylabel ('Amplitude');
plot(t,y); grid on xlabel ('Time Index');
axis([0 t(end) -1.2 1.2]) title('Exponential growing Signal');
title("Sine Wave")
xlabel("Time")
ylabel("Amplitude") %Program for Exponential decaying signal
t=0:0.1:10;
y=exp(-t);
%Program for Cosine Wave subplot(4,2,6)
t= 0 : 0.01 : 6 ; plot(t,y,"r"); grid on
y= cos(2*pi*t); ylabel ('Amplitude');
subplot(4,2,2) xlabel ('Time Index');
plot(t,y); grid on title('Exponential decaying Signal');
axis([0 t(end) -1.2 1.2])
title("Cosine Wave")
xlabel("Time") %Program for Sawtooth wave
ylabel("Amplitude") t= 0:0.001:19 ;
z= sawtooth(t);
subplot(4,2,7)
%Program for Square wave plot(t,z,"m"); grid on
t= 0:0.001:12 ; title('Sawtooth Wave');
z= square(t); xlabel('Time');
subplot(4,2,3) ylabel('Amplitude');
plot(t,z,"g"); grid on axis([0 t(end) -1.2 1.2])
title('Square wave');
xlabel('Time');
ylabel('Amplitude'); %Program for Triangular wave
axis([0 t(end) -1.2 1.2]) t= 0:0.1:19 ;
z= sawtooth(t,0.5);
subplot(4,2,8)
%Program for Sinc Pulse plot(t,z,"m"); grid on
t=-10:.01:10; title('Triangular Wave');
y=sinc(t); xlabel('Time');
subplot(4,2,4) ylabel('Amplitude');
plot(t,y,"g") axis([0 t(end) -1.2 1.2])
axis([-10 10 -2 2]);
ylabel ('Amplitude');
xlabel ('Time');
title('Sinc Pulse');
Output:
Discrete time signals:
clear all
Discussion:
In this lab, we successfully generated and visualized both continuous and discrete-time signals
using MATLAB. The continuous-time signal, represented by a sine wave, was created using a
finely sampled time vector, resulting in a smooth waveform that effectively models real-world
phenomena. The discrete-time signal, represented by a cosine wave, was generated using discrete
time points and visualized with the `stem` function, highlighting its distinct and discrete nature.
The comparison between continuous and discrete-time signals emphasized their respective
applications: continuous signals are crucial in analog domains such as audio processing and
communications, while discrete signals are essential in digital signal processing. MATLAB's
capabilities in signal generation and visualization proved invaluable in exploring these
fundamental concepts.
This lab reinforced theoretical knowledge from lectures, providing practical experience in
generating and analyzing signals. It demonstrated the transition from continuous to discrete
representations and their significance in various fields, including communications, control
systems, and medical imaging.
Submitted To
Abu Zahed Chowdhury
Associate Professor
Department of Electrical & Electronic Engineering
University of Chittagong
Submitted By
Name: Md Arman Kabir
ID: 20702061
Department of Electrical & Electronic Engineering
University of Chittagong
Apparatus required:
Hardware: Personal computer.
Software: Matlab 2014a.
Theory:
1. The mean square value of a random process can be obtained from the auto-
correlation function R(Z).
2. R(Z) is even function Z.
3. R(Z) is maximum at Z = 0 e.e. |R(Z)| ≤ R (0). In other words, this means the
maximum value of R(Z) is attained at Z = 0.
4. If R(Z) is the auto-correlation of a stationary random process {x(t)} with no periodic
components and with non-zeros means then limz→∞R(Z)=[E(x)]2.
Cross Correlation Function: The cross-correlation function is a metric used to quantify the
degree of similarity or coherence between two distinct signals. It assesses how one signal
aligns with a time-delayed version of another signal. Notably, the cross-correlation function
is defined differently for energy (aperiodic) signals and power (periodic) signals.
Procedure:
Start the MATLAB program.
Type the program.
Compile and Run the program.
For the output see command window\ Figure window.
Flowchart:
Program Code:
Correlation Sequence:
Autocorrelation Sequence:
clear all
n= 0:1:5*pi ;
x= sin (n);
subplot(2,1,1)
stem(x,'filled');
grid minor
xlabel('n');
ylabel('Amplitude');
title('Input sequence (Sine Wave)');
z= xcorr(x,x);
subplot(2,1,2)
stem(z,'filled',"r");
grid minor
xlabel('n');
ylabel('Amplitude');
title('Output sequence');
clc
clear all
n= 0:1:3*pi ;
x= sin (n);
y= cos (n);
%) Linear Convolutions
lin = conv(x,y);
subplot(2,1,1)
stem(lin,'filled',"r")
grid minor
xlabel('n');
ylabel('Amplitude');
title('Linear Convolution of x and y')
%) Linear Convolutions
circ = ifft(fft(x).*fft(y));
subplot(2,1,2)
stem(circ,'filled',"g")
grid minor
xlabel('n');
ylabel('Amplitude');
title('Circular Convolution of x and y')
Output:
Result:
Thus, the MATLAB programs for auto correlation, cross correlation, linear convolution and
circular convolution have written and the results were plotted.
Discussion:
The experiment successfully illustrated the concepts of correlation sequences, linear convolution,
and circular convolution using MATLAB. Correlation sequences revealed the similarity between
input sequences at different lags, essential for applications like pattern recognition and signal
detection. Linear convolution demonstrated how an input signal is modified by a system's
impulse response, crucial for filtering and system analysis, showing the cumulative effect of the
input on the system's output.
Circular convolution highlighted the periodic nature of signals in digital signal processing,
providing a perspective distinct from linear convolution, especially in applications involving the
Fast Fourier Transform (FFT). This operation showed how periodic extensions of sequences
influence convolution results.
Overall, the experiment provided a practical understanding of these fundamental signal
processing operations, emphasizing their importance in analyzing signal behavior and system
responses, and laying the groundwork for more advanced techniques in the field.
Answer: The purpose of correlation in signal processing is to measure the similarity between
two sequences. It helps in identifying patterns, detecting signals, and analyzing the relationship
between sequences at different lags.
Submitted To
Abu Zahed Chowdhury
Associate Professor
Department of Electrical & Electronic Engineering
University of Chittagong
Submitted By
Name: Md Arman Kabir
ID: 20702061
Department of Electrical & Electronic Engineering
University of Chittagong
Start
Launch MATLAB
Error? Yes
No
View the output in the command
window or figure window
End
Source Code:
Output:
The effect of Interpolation process:
clc
t = 0:1/1e3:1;
x = sin(2*pi*30*t) + sin(2*pi*60*t);
y = interp(x,4);
subplot(2,1,1)
stem(0:30,x(1:31),'filled',"g",'MarkerSize',3)
grid on
xlabel('Sample Number')
ylabel('Amplitude')
title('Input sequence')
subplot(2,1,2)
stem(0:120,y(1:121),'filled','MarkerSize',3)
grid on
xlabel('Sample Number')
ylabel('Amplitude')
title('Interpolated output sequence')
Output:
Results:
Thus, the MATLAB programs for the effect of up-sampling in frequency domain and the effect
of Interpolation process written and the results were plotted.
Discussion:
The experiment effectively illustrated the effects of up-sampling in the frequency domain and the
interpolation process using MATLAB. Up-sampling increased the sampling rate by inserting
zeros between the original samples, resulting in an expanded spectrum with replicated copies of
the original signal's spectrum. This demonstrated the importance of filtering to avoid aliasing and
maintain signal integrity.
The interpolation process, which estimates intermediate values to increase signal resolution and
smoothness, was also successfully demonstrated. Interpolation is crucial for applications
requiring high-quality signal reconstruction, such as audio processing and image enhancement.
The practical implementation in MATLAB provided valuable insights into these processes,
showing how they influence both time-domain and frequency-domain characteristics of signals.
Understanding these fundamental operations is essential for various signal processing
applications, enabling efficient manipulation and analysis of signals. This experiment reinforced
the theoretical concepts with practical examples, laying the groundwork for more advanced
signal processing techniques.
Answer: The purpose of up-sampling is to increase the sampling rate of a signal, which is often
necessary for preparing the signal for further processing, such as digital-to-analog conversion or
filtering.
2. How is up-sampling performed in the time domain?
Answer: Up-sampling in the time domain is performed by inserting zeros between the original
samples of the signal, effectively increasing the number of samples.
3. What is the effect of up-sampling on the signal's spectrum in the frequency domain?
Answer: Up-sampling results in the original spectrum being replicated at multiples of the new
sampling rate, expanding the frequency domain representation of the signal.
Answer: Filtering is necessary after up-sampling to remove the replicated copies of the original
spectrum and prevent aliasing, ensuring that the up-sampled signal retains its integrity.
Answer: Interpolation is the process of estimating intermediate values between known data
points to increase the resolution or smoothness of a signal.
Answer: Interpolation improves signal quality by generating a smoother and more continuous
representation of the signal, which is important for applications requiring high-quality
reconstruction.
Answer: Common interpolation methods include linear interpolation, cubic interpolation, and
spline interpolation, each offering different levels of smoothness and accuracy.
9. What MATLAB function is used for interpolation?
Answer: Up-sampling increases the sampling rate by inserting zeros, affecting the frequency
domain by replicating the spectrum. Interpolation, on the other hand, estimates intermediate
values to increase resolution and smoothness, enhancing the quality of the signal in the time
domain.