Comm 3
Comm 3
net/publication/367541658
CITATIONS READS
0 232
2 authors, including:
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Saudi Arabia License Plate Detection based on ANN and Objects Analysis View project
All content following this page was uploaded by Amr Ezz Eldin Rashed on 30 January 2023.
Prepared by:
Dr. Amr Ezzeldin Rashed
Chat GPT3 (an AI language model trained by OpenAI)
Page 1 of 70
Course Learning Outcomes
1. Understand the basic principles of analog and digital communication systems.
2. Analyze and design basic analog communication systems, such as AM and FM radio
systems.
3. Analyze and design basic digital communication systems, such as pulse code modulation
(PCM) and digital modulation techniques (ASK, PSK, FSK)
4. Understand and apply signal processing techniques, such as filtering and demodulation, to
analog and digital communication systems.
5. Understand and apply noise reduction techniques, such as signal-to-noise ratio (SNR) and
error correction coding, to improve the performance of analog and digital communication
systems.
6. Understand and apply modulation and demodulation techniques, such as amplitude, phase,
and frequency modulation and demodulation.
7. Understand and apply multiplexing techniques, such as frequency-division multiplexing
(FDM) and time-division multiplexing (TDM).
8. Understand and apply digital modulation techniques, such as digital baseband and passband
modulations.
9. Understand and apply the concepts of signal-to-noise ratio, BER, and QAM.
10. Understand and apply concepts of Analog and Digital modulation and demodulation
techniques in practical communication systems.
Instructions to Students:
1. This lab manual is designed to provide students with hands-on experience in the design,
implementation, and analysis of analog and digital communication systems.
2. Before starting the lab, students are expected to have a basic understanding of the concepts
of analog and digital communication systems covered in the corresponding lecture course.
3. Students are required to work in groups of two or three and should divide the lab work among
themselves fairly and efficiently.
4. Each lab session will consist of a pre-lab assignment, which must be completed and
submitted before the lab. The pre-lab assignment will consist of theoretical questions related
to the lab experiment and will be used to check the students' understanding of the concepts
covered in the lab.
5. Students are expected to arrive on time for each lab session and must stay for the entire
duration of the lab.
6. Students are required to wear appropriate clothing and footwear for the lab, including closed-
toe shoes and long pants.
7. Students must follow all safety procedures and guidelines outlined in the lab manual and
must be familiar with the location and use of all safety equipment in the lab.
8. Students are responsible for the proper use and maintenance of all equipment and materials
used in the lab. Any damages or loss of equipment will be the responsibility of the student(s)
involved.
Page 2 of 70
9. Students are expected to keep a lab notebook, in which they should record all observations,
calculations, and results for each lab experiment. The lab notebook will be checked by the
lab instructor during the lab session and should be kept for future reference.
10. At the end of each lab session, students will be required to submit a lab report, which should
include a detailed description of the experimental setup, data analysis, and results. The lab
report should also include a discussion of the results, including any observations and
conclusions.
11. The final grade for the lab will be based on the pre-lab assignments, lab notebook, lab
reports, and participation in the lab sessions.
Page 3 of 70
Content:
1 Introduction to Analog and Digital Communication
1.1 Overview of analog and digital communication systems.
1.2 Comparison of analog and digital signals.
1.3 Explanation of why modulation is necessary.
1.4 Applications of digital and analog communication systems.
2 Introduction to MATLAB
2.1 Historical background and evolution of MATLAB.
2.2 Explanation of MATLAB's use in communication systems.
2.3 Overview of applications of MATLAB in communication systems.
2.4 Getting Started with MATLAB for communication systems.
3 Signal Analysis in MATLAB
3.1 Time-domain analysis (signal plotting, RMS, etc.).
3.2 Frequency-domain analysis (FFT, PSD, etc.).
3.3 Analysis of signals with noise and distortion.
4 Signal Generation in MATLAB
4.1 Synthesis of basic signals (sine, square, etc.).
4.2 Signal classification
4.3 Generation of complex signals using modulation and superposition.
4.4 Use of noise generators for signal analysis.
4.5 Difference between gaussian noise and white noise
5 Modulation Techniques
5.1 Analog Modulation Techniques
5.2 Amplitude Modulation (AM).
5.3 Example 1: Generate an AM DSB-SC signal with a carrier frequency of 1kHz and a
modulation index of 0.8 using MATLAB (built-in function).
5.4 Example 2: Generate an AM DSB-SC signal with a carrier frequency of 1kHz and a
modulation index of 0.8 using MATLAB.
Page 4 of 70
5.5 Example 3: Generate an AM SSB-SC signal with a carrier frequency of 1kHz and a
modulation index of 0.8 using MATLAB.
5.6 Frequency Modulation (FM).
5.7 Example 4: Generate an FM signal with a carrier frequency of 1kHz, a modulation index of
0.8, and a deviation of 100Hz using MATLAB.
5.8 Phase Modulation (PM).
5.9 Example 5: Generate a PM signal with a carrier frequency of 1kHz and a modulation index of
0.5 using MATLAB.
6 Sampling and Quantization in MATLAB
6.1 Overview of sampling types (flat top, natural, etc.)
Page 5 of 70
Acknowledgment
We would like to extend our deepest gratitude and appreciation to the Dean of the Faculty of the
College of Computers and Information Technology, Dr. Hesham Alhumyani, for his unwavering support
and guidance throughout the creation of this lab manual. We would also like to thank the Vice Dean, Dr.
Wael Alosiemy, and the Head of the Department of Computer Engineering, Dr. Samir Elsherif, for their
valuable contributions and insights. We are also greatly appreciative of the hard work and dedication of
the entire staff at the Faculty of College of Computers and Information Technology, who have provided
us with the resources and support necessary to complete this lab manual. Finally, we would like to express
our gratitude to all the students who have participated in this lab manual, their efforts and feedback were
essential in making this manual a success.
Page 6 of 70
1 Introduction to Analog and Digital Communication
1.1 Overview of analog and digital communication systems.
This is a comprehensive overview of analog and digital communication systems, with the help of
MATLAB. It covers the introduction, signal analysis, signal generation, modulation techniques, digital
modulation, and the conclusion with the future scope of research in this field. This lab manual provides a
good foundation for the students to understand the concepts of communication systems and how to use
MATLAB to simulate and analyze them.
• Analog and digital communication systems are methods for transmitting information from one
place to another. In an analog communication system, the information is transmitted in the form
of continuous electrical signals, such as sound or video. In a digital communication system, the
information is transmitted in the form of discrete digital signals, such as binary code.
• Analog communication systems have been in use for over a century and are still widely used today
in applications such as radio and television broadcasting, telephone systems, and audio recording.
These systems are known for their ability to transmit high-fidelity signals, but they are also
susceptible to noise and interference.
• Digital communication systems, on the other hand, have only been in widespread use for a few
decades. They are used in a wide range of applications, including computers, cell phones, and the
internet. Digital communication systems are known for their immunity to noise and interference,
and they also provide more efficient use of the available bandwidth. However, the conversion
process of analog signal to digital signal is lossy, which results in the degradation of the original
signal.
In summary, both analog and digital communication systems have their advantages and disadvantages.
Analog systems are good for transmitting high-fidelity signals, but they are susceptible to noise and
interference. Digital systems are immune to noise and interference, but they may not provide the same
level of signal quality as analog systems.
Page 7 of 70
Digital signals, on the other hand, are discrete signals that can only take on a limited set of values.
The most common digital signals are binary signals, which can only take on values of 0 or 1. Digital
signals are often used in applications such as computers, cell phones, and the internet.
➢ There are a few key differences between analog and digital signals:
• Quality: Analog signals are known for their high-fidelity and ability to transmit a wide range of
information. Digital signals, however, may not provide the same level of signal quality as analog
signals, as the conversion process from analog to digital is lossy, resulting in the degradation of
the original signal.
• Noise and Interference: Analog signals are susceptible to noise and interference, which can cause
distortion in the signal. Digital signals are immune to noise and interference, as errors can be
detected and corrected using error-correction codes.
• Bandwidth: Analog signals require a larger bandwidth than digital signals to transmit the same
amount of information. This is because analog signals are continuous and can take on any value,
while digital signals are discrete and can only take on a limited set of values.
• Storage and Processing: Analog signals are difficult to store and process, while digital signals can
be easily stored and processed using computers.
In summary, while both analog and digital signals have their advantages and disadvantages, digital
signals are more suitable for modern applications such as computers and the internet.
Page 8 of 70
In summary, modulation is a necessary process for effectively transmitting information over a
communication channel. It allows us to overcome the limitations of the channel, such as limited
bandwidth, noise and interference, distance and power constraints, and spectrum allocation.
1.4 Applications of digital and analog communication systems.
Analog communication systems and digital communication systems have different applications,
each with its own set of advantages and disadvantages.
➢ Applications of Analog Communication Systems:
• Radio and Television Broadcasting: Analog systems are used for the transmission of radio and
television signals. They are known for their ability to transmit high-fidelity signals, and they
provide a wide range of information.
• Telephone Systems: Analog systems are still used in telephone systems, particularly in the form
of the Public Switched Telephone Network (PSTN). They are reliable and provide a clear voice
quality.
• Audio Recording: Analog systems are used in audio recordings and playbacks, such as cassette
tapes and vinyl records. They provide a high-fidelity and warm sound.
• Instrumentation and Control: Analog systems are used in instrumentation and control systems,
such as in measuring temperature, pressure, and voltage. They provide accurate and precise
measurements.
• Computers and the Internet: Digital systems are used in computers and the internet, providing the
foundation for data communication and networking. They are immune to noise and interference,
and they provide more efficient use of the available bandwidth.
• Cellular Communications: Digital systems are used in cellular communications, such as in cell
phones and mobile networks. They provide more secure and reliable communication, and they
support the integration of various services such as voice, data, and video.
• Digital Television: Digital systems are used in digital television, providing a higher-quality picture
and sound.
• Navigation: Digital systems are used in navigation systems, such as GPS and satellite navigation,
providing precise location and guidance information.
In summary, both analog and digital communication systems have their own unique advantages and
disadvantages, and each is more suitable for certain types of applications. While digital communication
systems are more suitable for modern applications such as computers and the internet, analog
communication systems are still used in applications that require high-fidelity signals and clear voice
quality.
Page 9 of 70
2 Introduction to MATLAB
2.1 Historical background and evolution of MATLAB.
MATLAB (Matrix Laboratory) was first developed in the late 1970s by a group of researchers at the
Massachusetts Institute of Technology (MIT). The initial focus of the project was to create a programming
environment for matrix manipulation, which was a common task in engineering and scientific research at
the time. The first version of MATLAB was released in 1984, and it quickly gained popularity among
engineers and scientists for its ability to perform complex mathematical computations in a relatively
simple and intuitive way.
Over the years, MATLAB has evolved to include a wide range of features and capabilities. In the early
1990s, the company MathWorks was founded to commercialize MATLAB, and it has since released
several updates and new versions of the software. Some of the key features added over the years include:
• The Signal Processing Toolbox, provides tools for signal processing and analysis.
• The Communications System Toolbox, provides tools for the simulation of communication
systems.
• The Image Processing Toolbox, provides tools for image processing and analysis.
• The Simulink toolbox, allows for the simulation of dynamic systems, such as control systems and
digital signal processing systems.
Over time, MATLAB has also been used in various industries, such as aerospace, automotive,
financial services, and telecommunications. The software is now widely used in universities and research
institutions, as well as in industry. It is considered one of the most popular programming languages in the
field of engineering and science.
In summary, MATLAB has a rich history and evolution. It started as a tool for matrix manipulation, but
over the years it has evolved to include a wide range of features and capabilities, making it a powerful
tool for a wide range of engineering and scientific applications. The software has been widely adopted in
industry and academia, and it continues to be updated and improved by MathWorks.
Page 10 of 70
➢ Some of the key features of MATLAB that are useful for communication systems
include:
• Signal Processing Toolbox: provides a wide range of tools for signal processing, including
filtering, modulation, and demodulation.
• Communications System Toolbox provides tools for the simulation of communication systems,
such as the ability to model channels, noise, and interference.
• Data Analysis and Visualization provide tools for the analysis and visualization of data, such as
plotting, statistics, and curve fitting.
• Simulation of analog and digital modulation techniques, such as AM, FM, PM, BPSK, QPSK, and
QAM.
• Analysis of the performance of communication systems, such as the bit error rate (BER) and
symbol error rate (SER) for digital systems and the modulation index and carrier-to-noise ratio for
analog systems.
• Implementation of channel coding techniques, such as error detection and correction codes and
convolutional codes.
• Design and simulation of wireless communication systems, such as cellular networks and satellite
systems.
In summary, MATLAB is a powerful tool for the simulation and analysis of communication systems. Its
wide range of signal processing and simulation tools, as well as data analysis and visualization capabilities,
make it an ideal choice for communication engineers and researchers.
Page 11 of 70
• Channel coding: MATLAB provides tools for the implementation of channel coding techniques,
such as error detection and correction codes and convolutional codes.
• Design and simulation of wireless communication systems: MATLAB can be used to design and
simulate wireless communication systems, such as cellular networks and satellite systems.
• Digital signal processing: MATLAB provides tools for digital signal processing, such as filtering,
modulation, demodulation, and equalization.
• Antenna design and analysis: MATLAB can be used for the design and analysis of antennas for
communication systems. It allows the user to simulate the radiation pattern and gain of different
antenna designs.
In summary, MATLAB is a powerful tool for the simulation and analysis of communication systems. Its
wide range of signal processing and simulation tools, as well as data analysis and visualization capabilities,
make it an ideal choice for communication engineers and researchers. It can be used for a wide range of
applications in communication systems, such as simulation, performance analysis, system optimization,
channel coding, wireless communication systems, digital signal processing, and antenna design and
analysis.
Page 12 of 70
In summary, the "Getting Started with MATLAB for Communication" section in the lab book would
provide a comprehensive introduction to using MATLAB for communication systems. It would cover
topics such as installation and setup, basic MATLAB commands and syntax, data visualization and signal
plotting, importing, and exporting signals, scripting and programming, debugging and error handling, and
examples and exercises for practice. This section would serve as a foundation for the readers to understand
the concepts of communication systems and how to use MATLAB to simulate and analyze them.
Installation and setup of MATLAB and relevant toolboxes
This section would cover the following topics:
1. Installing MATLAB: The first step in getting started with MATLAB for DSP is to install the
software. This section would provide instructions on how to download and install the latest version
of MATLAB, including any necessary license information.
2. Installing relevant toolboxes: MATLAB has several toolboxes that are specifically designed for
DSP and other related fields. This section would provide instructions on how to install the relevant
toolboxes for DSP, such as Signal Processing Toolbox, Image Processing Toolbox, and Control
System Toolbox.
3. Configuring MATLAB preferences: Once MATLAB and the relevant toolboxes are installed, this
section would guide the readers on how to configure the preferences and settings in MATLAB.
This includes setting the path for the toolboxes, configuring the interface, and customizing the
layout.
4. Verifying the installation: This section would provide instructions on how to verify the installation
of MATLAB and the relevant toolboxes, including how to run test scripts and verify that the
toolboxes are properly installed and functioning.
5. Updating MATLAB and toolboxes: This section would cover the process of updating MATLAB
and the toolboxes to the latest version, including the necessary steps and precautions to take before
updating.
MATLAB can be installed on a variety of platforms such as Windows, Linux, and MacOS. The
installation process for each platform is slightly different but generally follows these steps:
1. Download the installation package for the desired version of MATLAB from the MathWorks
website.
2. Run the installation package and follow the prompts to install MATLAB. This may include
agreeing to the license agreement, selecting the installation location, and specifying the
components to install.
3. Once the installation is complete, MATLAB will prompt you to activate the software. This can
be done by providing your MathWorks account information or by providing a license key.
4. After the activation is complete, MATLAB can be launched by clicking on the MATLAB icon
on the desktop or by searching for it in the start menu (Windows) or the Applications folder
(MacOS).
5. Before starting to use MATLAB, it is recommended to install the latest updates and additional
toolboxes which are available through MATLAB's Help menu.
Page 13 of 70
6. It is also important to note that MATLAB requires a powerful computer and a compatible
graphics card to run efficiently. The recommended system requirements can be found on the
MathWorks website.
The installation process for MATLAB can vary depending on the platform, but in general, it is
straightforward to follow. It is important to ensure that the system meets the minimum requirements and
that the correct version and toolboxes are selected during the installation process. Once installed and
activated, the software can be used for a wide range of tasks such as data analysis, visualization, and signal
processing.
MATLAB comes with a set of built-in toolboxes, but additional toolboxes can be installed to extend the
functionality of the software. Toolboxes are collections of functions and data that are specific to a certain
area of application, such as signal processing, control systems, or image processing.
1. To install additional toolboxes, you first need to launch MATLAB and go to the "Home" tab, then
click on the "Add-Ons" button.
2. Select the "Get Add-Ons" option to open the Add-On Explorer.
3. In the Add-On Explorer, you can browse through the available toolboxes and select the ones that
you want to install. You can filter the toolboxes by application area, vendor, or even type of license.
4. Once you have selected the toolboxes to install, click on the "Download" button to begin the
installation process.
5. After the installation is complete, the toolboxes will be available in the "Add-Ons" menu of the
MATLAB Home tab.
6. Some toolboxes may require additional software to be installed or may have specific system
requirements, so it is important to read the documentation for each toolbox before installing it.
7. Additionally, some toolboxes may require a separate license to be able to use it.
Installing additional toolboxes in MATLAB is a simple process that can be done through the Add-On
Explorer. This allows users to extend the functionality of MATLAB and to access specialized functions
for certain areas of application. It is important to read the documentation for each toolbox.
In summary, installing and setting up MATLAB and relevant toolboxes is a straightforward process that
involves obtaining the software, installing it, activating it, installing the relevant toolboxes, and then
verifying that everything is working correctly. With that, you will be able to use the full functionality of
MATLAB and the toolboxes to simulate and analyze communication systems.
MATLAB provides a wide range of preferences that can be configured to customize the appearance
and behavior of the software. These preferences can be accessed through the "Home" tab, then by clicking
the "Preferences" button. Some examples of preferences that can be configured include:
1. General: This section allows you to configure the startup folder, the command window, and the
current folder.
2. Editor/Debugger: This section allows you to configure the appearance of the editor, such as the
font size and color scheme, and the behavior of the debugger, such as the number of function calls
to display in the call stack.
Page 14 of 70
3. Keyboard: This section allows you to customize the keyboard shortcuts for various MATLAB
commands.
4. Colors: This section allows you to configure the colors used in the MATLAB interface, such as
the colors used for the command window and the editor.
5. Current Folder: This section allows you to configure the default location for saving and opening
files.
6. Web: This section allows you to configure the web preferences, such as the default web browser
and proxy settings.
7. MATLAB > Desktop: This section allows you to configure the appearance and behavior of the
MATLAB desktop, such as the layout and size of the windows.
8. MATLAB > Workspace: This section allows you to configure the preferences for the workspace,
such as the format of the data and the number of decimal places displayed.
These are just some examples of the preferences that can be configured in MATLAB. The software
provides a wide range of options for customizing the appearance and behavior of the software to suit the
user's needs. It is recommended to experiment with different settings and find the configuration that works
best for you.
Once MATLAB and any additional toolboxes have been installed, it is important to verify that the
installation was successful and that everything is working properly. Here are some steps to verify the
installation:
1. Launch MATLAB by clicking on the MATLAB icon on the desktop or by searching for it in the
start menu (Windows) or the Applications folder (MacOS).
2. Verify that the version of MATLAB displayed in the splash screen matches the version that was
installed.
3. Check that all the toolboxes that were installed are listed in the "Add-Ons" menu of the MATLAB
Home tab.
4. Try running some basic commands, such as "2+2" in the command window to check that the
software is functioning properly.
5. Check the "Help" menu to verify that the documentation for all the toolboxes that were installed
is accessible.
6. Try running a sample script or function that uses the toolboxes that were installed to ensure that
they are working properly.
7. Check that the preferences that were configured during the installation are set correctly.
8. Verify that the license for the software is valid, by running the command "ver" in the command
window, which should show the license number, expiration date, and the toolboxes that are
covered by the license.
Verifying the installation of MATLAB and any additional toolboxes is an important step to ensure
that the software is functioning properly. By following these steps, you can verify that the installation was
successful and that everything is working as expected. If any issues are encountered during the verification
process, refer to the MathWorks website or contact MathWorks support for assistance.
Page 15 of 70
It is important to keep MATLAB and the installed toolboxes up to date to benefit from the latest
features, bug fixes, and security updates. Here are some steps to update MATLAB and toolboxes:
1. Open MATLAB and navigate to the "Help" menu, then select "Check for Updates". This will open
the "Update" window.
2. In the "Update" window, you will be able to see if there are any updates available for MATLAB
and the installed toolboxes. Select the updates that you wish to install.
3. Click on the "Download and Install" button to begin the update process.
4. Follow the prompts to complete the update process.
5. After the update is complete, it is recommended to restart MATLAB to ensure that the changes
take effect.
6. You can also check for updates by going to the MathWorks website and downloading the latest
version, then installing it using the installer.
It is important to regularly check for updates to keep MATLAB and the installed toolboxes up to date.
By doing so, you can benefit from the latest features and bug fixes, and ensure that the software is running
smoothly. It is also important to note that some updates may require a new license or may have specific
system requirements, so it is important to read the documentation for each update before installing it.
A. Data types and variables: MATLAB uses different data types, such as scalars, vectors, matrices,
and arrays, to represent signals. This section would introduce the basic data types used in
MATLAB and the syntax for creating and manipulating them.
B. Vector and matrix operations: MATLAB provides a wide range of operations for working with
vectors and matrices. This section would cover the basic operations such as addition, subtraction,
multiplication, and transposition. It would also cover advanced operations like element-wise
operations, matrix decomposition, and solving linear equations.
C. Signal processing functions: MATLAB provides a wide range of built-in functions for signal
processing, such as filtering, convolution, and modulation. This section would introduce the basic
functions and their usage for signal processing in MATLAB.
This section would provide the readers with a basic understanding of the MATLAB commands and
syntax used in signal processing. It would cover the most commonly used data types, variables, and
functions, and provide an introduction to the basic operations and functions used in DSP. The readers are
encouraged to experiment with the provided examples and exercises to gain hands-on experience with the
concepts and techniques covered in this section.
Page 16 of 70
A. Data types and variables
In MATLAB, data can be represented using different data types, such as scalars, vectors, matrices,
and arrays. MATLAB uses variables to store and manipulate data. Variables can be created by simply
assigning a value to a name, for example:
1. Scalars: A scalar is a single value that can be a number, a character or a logical value (true or false).
Scalars can be created by simply assigning a value to a variable, for example:
a = 3;
2. Vectors: A vector is an array of numbers arranged in a single column or row. Vectors can be
created in MATLAB by enclosing a list of numbers in square brackets, for example:
v = [1 2 3 4 5];
3. Matrices: A matrix is a two-dimensional array of numbers. Matrices can be created in MATLAB
by enclosing a list of numbers in square brackets, separated by semicolons, for example:
M = [1 2 3; 4 5 6; 7 8 9];
4. Arrays: An array is a multi-dimensional collection of data, which can be a combination of scalars,
vectors, and matrices. Arrays can be created in MATLAB by specifying the dimensions of the
array and the elements, for example:
A = zeros(2,3,4);
variable names cannot be reserved words and must start with a letter. They can contain letters,
numbers, and underscores, but not spaces. It is recommended to choose descriptive and meaningful names
for variables to make code easier to understand and maintain.
MATLAB uses several built-in functions for handling and manipulating data types and variables.
For example, the size() function can be used to determine the dimensions of an array, and the reshape()
function can be used to change the dimensions of an array. The readers are encouraged to experiment with
the provided examples and exercises to gain hands-on experience with the concepts and techniques
covered in this section.
Matlab special values:
In MATLAB, some of the special values include:
1. pi: Representation of the mathematical constant pi (approximately 3.14159).
2. inf: Representation of positive infinity.
3. NaN: Representation of Not-A-Number (Undefined result).
4. eps: Representation of the smallest positive floating point number that is greater than 0.
5. beep: Produces an audible sound.
6. ans: Contains the result of the most recent expression that was not assigned to a variable.
7. realmax: Largest representable positive floating point number.
8. realmin: Smallest representable positive floating point number.
9. i: Square root of -1, used as the imaginary unit in complex numbers.
10. j: Alternative representation of the imaginary unit.
Page 17 of 70
These values can be used in MATLAB expressions and calculations just like any other variable.
B. Vector and matrix operations
In MATLAB, vectors and matrices can be manipulated using various operations such as addition,
subtraction, multiplication, and transposition. These operations allow for the manipulation and analysis of
signals and data.
1. Addition and subtraction: Vectors and matrices can be added and subtracted elementwise, for
example:
a = [1 2 3];
b = [4 5 6];
c = a + b; % results in [5 7 9]
d = a - b; % results in [-3 -3 -3]
2. Multiplication: Vectors and matrices can be multiplied elementwise, for example:
a = [1 2 3];
b = [4 5 6];
c = a .* b; % results in [4 10 18]
Matrix multiplication can also be done using the matrix multiplication operator (*) or the matrix
multiplication function (mtimes)
a = [1 2 3];
b = [4 5 6];
c = a * b.';
3. Transpose: The transpose of a vector or matrix can be taken using the transpose operator (') or the
transpose function (transpose), for example:
a = [1 2 3];
b = a.'; % results in [1; 2; 3]
4. Other operations:
• The inverse of a matrix can be obtained using the inv() function
• The determinant of a matrix can be obtained using the det() function
• The eigenvalues and eigenvectors of a matrix can be obtained using the eig() function
• Matrix decomposition can be obtained using the LU, QR and SVD decomposition functions such
as lu(), qr(), svd()
• Solving linear equations can be done using linsolve() function
These are some basic examples of vector and matrix operations in MATLAB. These operations are
widely used in DSP for analyzing and processing signals and data. The readers are encouraged to
experiment with the provided examples and exercises to gain hands-on experience with the concepts and
techniques covered in this section.
Page 18 of 70
In MATLAB, matrices can be manipulated using various operations such as addition, subtraction,
multiplication, and transposition. These operations allow for the manipulation and analysis of signals and
data.
1. Addition and subtraction: Matrices can be added and subtracted element-wise, for example:
A = [1 2 3; 4 5 6; 7 8 9];
B = [10 11 12; 13 14 15; 16 17 18];
C = A + B; % results in [11 13 15; 17 19 21; 23 25 27]
D = A - B; % results in [-9 -9 -9; -9 -9 -9; -9 -9 -9]
3. Transpose: The transpose of a matrix can be taken using the transpose operator (') or the transpose
function (transpose), for example:
A = [1 2 3; 4 5 6; 7 8 9];
B = A.'; % results in [1 4 7; 2 5 8; 3 6 9]
4. Other operations:
• The inverse of a matrix can be obtained using the inv() function
• The determinant of a matrix can be obtained using the det() function
• The eigenvalues and eigenvectors of a matrix
Page 19 of 70
2. Convolution: MATLAB provides several functions for the convolution of signals, such as conv()
and conv2() functions.
x = [1 2 3];
h = [4 5 6];
y = conv(x,h);
This will convolve the two signals x and h and return the convolution result in the y.
3. Modulation: MATLAB provides several functions for the modulation of signals, such as:
• ammod() function for Amplitude Modulation (AM) of a signal.
• fmmod() function for Frequency Modulation (FM) of a signal.
• pmdemod() function for Phase Modulation (PM) demodulation of a signal.
Page 20 of 70
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
stem(n,x);
This will create a stem plot of the signal with the discrete time-steps on the x-axis and the amplitude on
the y-axis.
3. scatter function: The scatter function is used to create scatter plots of vector data. It is commonly
used to plot two-dimensional data, for example:
x= randn(100,1);
y = randn(100,1);
scatter(x,y);
This will create a scatter plot of the two-dimensional data, with the values of x on the x-axis and the values
of y on the y-axis.
4. Other visualization functions:
3. Other functions: MATLAB also provides functions for importing and exporting signals in other
formats such as .mat for importing and exporting data in the native MATLAB format, and load()
and save() functions for importing and exporting data in .mat format.
load('inputfile.mat');
save('outputfile.mat');
4. Importing and exporting signals from external devices: MATLAB also provides functions and
toolboxes for importing and exporting signals from external devices such as audio and video input
and output, serial communication, and network communication. These functions and toolboxes
allow for the real-time acquisition and analysis of signals from external devices.
In summary, MATLAB provides several methods for importing and exporting signals in different
formats, such as audio, images, and other data types. These methods allow for the manipulation and
analysis of signals in MATLAB, and the export of the results to other formats. This allows for easy
integration with other software and systems.
5 Scripting and programming
MATLAB provides a scripting environment for writing programs and functions. This allows for the
automation of tasks, the creation of custom functions, and the ability to process large amounts of data.
1. Scripts: A script is a collection of MATLAB commands that can be executed in order. Scripts can
be created by creating a new file in the MATLAB editor and saving it with the extension ".m", for
example, "myScript.m". Scripts can be executed by typing the name of the script (without the ".m"
extension) in the command prompt or by clicking the "Run" button in the MATLAB editor.
2. Functions: A function is a block of code that can be reused multiple times. Functions can be created
by creating a new file in the MATLAB editor and saving it with the extension ".m", for example
"myFunction.m". The first line of the function should define the function signature, which includes
the function name, input arguments, and output arguments. Functions can be called by typing the
name of the function followed by the input arguments in the command prompt.
function [output] = myFunction(input)
% function code
end
3. Flow control: MATLAB provides several flow control statements such as if-else, for, and while
loops that allow for the control of the flow of execution of a script or function. For example:
for i=1:10
disp(i);
end
Page 22 of 70
4. Cell mode and script debugging: MATLAB has a cell mode feature that allows users to run code
in blocks and the ability to set breakpoints and step through the code. This feature is useful for
debugging code and understanding how it works.
This section provides an overview of the basic features of scripting and programming in MATLAB.
Scripts and functions are powerful tools that allow for the automation of tasks and the ability to process
large amounts of data. The readers are encouraged to experiment with the provided examples and exercises
to gain hands-on experience with the concepts and techniques covered in this section.
6 Debugging and error handling
Debugging and error handling are important aspects of programming in any language, and MATLAB
provides several tools to make it easier for users to debug and handle errors in their code.
It is important to use these tools to ensure the code is reliable and robust. It is also important to test
and validate the code before deploying it.
1. Error messages: When an error occurs in a script or function, MATLAB will display an error
message indicating the type of error and the line number where the error occurred. This information
can be used to locate and fix the error in the code.
2. Try-catch statement: The try-catch statement allows for the handling of errors in a script or
function. It allows for the execution of a block of code, and if an error occurs, it will execute a
separate block of code to handle the error.
try
catch ME
end
3. Debug mode: MATLAB provides a debug mode that allows users to step through the execution of
a script or function, and to examine the values of variables at different points in the code. This
mode can be entered by clicking the "Debug" button in the MATLAB editor or by typing "debug"
in the command prompt.
4. Keyboard commands: MATLAB provides a set of keyboard commands for debugging, such as
"step" to step through the code, "next" to execute the next line, "break" to set a breakpoint, "watch"
to watch variables, and "clear" to clear breakpoints.
5. Profiler: MATLAB also has a built-in profiler that allows users to measure the performance of the
code and identify bottlenecks in the execution time.
6. M-lint: MATLAB has a built-in tool called M-lint which checks the code for potential errors, and
inconsistencies and can also suggest improvements. By using this tool, one can find and fix errors
in the code before running it.
Page 23 of 70
7. Assertions: An assertion is a statement that checks if a given condition is true or not, and throws
an error if the condition is not met. For example, if you want to check if a variable is positive
before using it in your code:
assert(x>0, 'x should be positive')
8. Logging: MATLAB allows users to log messages to track the execution of the code. The log
messages can include information such as variable values, execution times, and error messages.
This allows for better tracking and understanding of the code's behavior.
These are some basic examples of debugging and error-handling techniques in MATLAB. These
techniques are essential for debugging code and understanding how it works. The readers are encouraged
to experiment with the provided examples and exercises to gain hands-on experience with the concepts
and techniques covered in this section.
Page 24 of 70
3 Signal Analysis in MATLAB
3.1 Time-domain analysis:
• Signal plotting:
t = 0:0.01:1;
x = sin(2*pi*10*t);
plot(t,x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Sine Wave');
This example plots a sine wave of frequency 10 Hz over the time of 1 second.
• Root mean square (RMS) value:
x = [1 2 3 4 5];
rms_val = rms(x);
disp(rms_val);
This example calculates the RMS value of the signal x = [1 2 3 4 5].
Page 25 of 70
3.3 Analysis of signals with noise and distortion:
• Filtering:
fs = 1000;
t = 0:1/fs:1;
x = sin(2pi50t) + 0.5randn(size(t));
b = [1 0 -1]; a = [1];
y = filter(b,a,x);
plot(t,x,'r',t,y,'b');
legend('Original','Filtered');
This example adds Gaussian white noise to a sine wave of frequency 50 Hz and applies a simple moving
average filter to remove the noise.
• Adaptive filtering:
fs = 1000;
t = 0:1/fs:1;
x = sin(2pi50t) + 0.5randn(size(t));
d = sin(2pi50*t);
mu = 0.001;
[y,e] = lms(x,d,mu);
plot(t,x,'r',t,y,'b');
legend('Original','Filtered');
This example adds Gaussian white noise to a sine wave of frequency 50 Hz and applies an LMS adaptive
filter to remove the noise. These are some examples of how to use MATLAB functions to perform signal
analysis in the time-domain, frequency-domain, and for signals with noise and distortion. Keep in mind
that these examples are just a starting point, and the actual analysis will depend on the specific
requirements of the signal and the application.
Page 26 of 70
4 Signal Generation in MATLAB:
4.1 Synthesis of basic signals:
MATLAB provides a wide range of functions for synthesizing basic signals such as sine, square,
triangle, and sawtooth waves. These functions include:
• sine wave: sin()
• square wave: square()
• triangle wave: sawtooth()
• sawtooth wave: sawtooth()
fs = 1000;
t = 0:1/fs:1;
x = sin(2*pi*50*t); % sine wave of frequency 50 Hz
y = square(2*pi*50*t); % square wave of frequency 50 Hz
z = sawtooth(2*pi*50*t); % sawtooth wave of frequency 50 Hz
4.2 Signal classification
Signals can be classified as:
1. Continuous/Discrete: Continuous signals have an uninterrupted flow of values over time.
Discrete signals have a finite number of values over time and are sampled at regular intervals.
Example in MATLAB:
Continuous:
t = 0:0.01:2*pi;
x = sin(t);
plot(t,x);
Discrete:
t = 0:10:100;
x = sin(t);
stem(t,x);
2. Analog/Digital: Analog signals are continuous in amplitude and time. Digital signals have
a finite number of discrete amplitude levels.
Example in MATLAB:
Analog:
t = 0:0.01:2*pi;
x = sin(t);
plot(t,x);
Digital:
t = 0:10:100;
x = sin(t);
stem(t,x);
3. Periodic/Aperiodic: Periodic signals repeat after a fixed interval. Aperiodic signals do not
repeat.
Example in MATLAB:
Page 27 of 70
Periodic:
t = 0:0.01:2*pi;
x = sin(t);
plot(t,x);
Aperiodic:
t = 0:0.01:2*pi;
x = sin(t) + randn(size(t));
plot(t,x);
4. Energy/Power: Energy signals have finite total energy over all time. Power signals have
finite average power over time.
Example in MATLAB:
Energy:
t = 0:0.01:2*pi;
x = sin(t).^2;
plot(t,x);
Power:
t = 0:0.01:2*pi;
x = sin(t);
plot(t,x.^2);
Page 28 of 70
In summary, MATLAB provides a wide range of functions and toolboxes for signal generation, covering
basic signals such as sine, square, triangle, and sawtooth waves, as well as more complex signals using
modulation and superposition techniques. Additionally, it also provides various noise generators which
can be useful for signal analysis. These functions and toolboxes allow for the creation and manipulation
of signals for various applications, such as testing and simulation. It's important to note that the accuracy
and effectiveness of the generated signal will depend on the specific requirements of the application, and
the chosen method and parameters.
4.5 Difference between Gaussian noise and white noise
Gaussian noise and white noise are both types of random noise, but they have some differences.
1. Probability Distribution: Gaussian noise, also known as normal noise, is a type of random noise
that follows a normal (or Gaussian) probability distribution. This means that the values of the noise
are distributed around a mean value with a certain standard deviation. White noise, on the other
hand, is a type of random noise that has a constant power density across all frequencies.
2. Spectral Density: Gaussian noise has a flat spectral density, which means that the power density
of the noise is constant across all frequencies. White noise, on the other hand, has a power spectral
density that is proportional to the frequency.
3. Applications: Gaussian noise is often used in signal processing and communication systems, where
it is added to a signal to simulate real-world noise and distortion. White noise is often used in other
fields such as audio processing, image processing, and control systems, where it is added to a
signal to evaluate the performance of a system or algorithm.
In summary, Gaussian noise and white noise are both types of random noise, but they have different
probability distributions and spectral densities, and they are used in different applications.
Page 29 of 70
5 Modulation Techniques:
1. Analog Modulation: modulation of analog signals such as AM, FM, and PM.
2. Digital Modulation: modulation of digital signals such as ASK, FSK, PSK, and QAM.
3. Pulse Modulation: modulation of pulse signals, which can be either analog over analog (such as
PAM, PWM, PPM, PFM) or analog over digital (such as PCM, DPCM, ADPCM, DM, ΔΣ,
CVSDM, ADM, PDM).
4. Miscellaneous Modulation Techniques: including Continuous Wave Modulation (used in radar
systems), Space Modulation (used in instrument landing systems), and the microwave auditory
effect modulated with audio waveforms.
Page 30 of 70
Applications of Analog modulation
Analog modulation techniques are widely used in various communication systems, such as radio
broadcasting, television broadcasting, and marine communication. These techniques have been used for
many years and continue to be used in many systems today. However, they also have some drawbacks,
such as susceptibility to interference and noise, and limited bandwidth efficiency.
One of the main advantages of analog modulation is its simplicity. It is relatively easy to understand and
implement, and it does not require complex signal processing. Additionally, analog modulation is robust
against noise and interference, which makes it suitable for use in harsh environments.
On the other hand, one of the main disadvantages of analog modulation is its limited bandwidth efficiency.
It requires a relatively large bandwidth to transmit a given amount of information, and this can be a
problem in systems where bandwidth is limited, such as satellite communication. Additionally, analog
modulation is susceptible to interference and noise, which can degrade the quality of the signal.
In recent years, digital modulation techniques have become increasingly popular, and they are now used
in many communication systems. Digital modulation techniques are more bandwidth efficient and less
susceptible to noise and interference, but they are also more complex and require more advanced signal
processing techniques.
In conclusion, analog modulation techniques are widely used in various communication systems, such as
radio broadcasting, television broadcasting, and marine communication. They have been used for many
years and continue to be used in many systems today. However, they also have some drawbacks, such as
susceptibility to interference and noise, and limited bandwidth efficiency. It's important to understand the
advantages and disadvantages of analog modulation techniques when choosing the appropriate modulation
technique for a given application.
5.2 Amplitude Modulation (AM)
Amplitude Modulation (AM) is a method of conveying a baseband message signal over a higher
frequency carrier signal by varying the amplitude of the carrier signal in proportion to the baseband signal.
The baseband signal is typically a low-frequency signal, such as an audio signal, and the carrier signal is
typically a high-frequency signal, such as a radio frequency signal.
The basic process of AM involves multiplying the baseband signal with a sinusoidal carrier signal,
resulting in a modulated signal. The modulated signal can then be transmitted over a communication
channel and demodulated at the receiver to recover the original baseband signal.
There are three types of AM:
1. Double-Sideband Suppressed Carrier (DSB-SC): This type of AM modulation method uses the
full amplitude of the modulating signal to vary the amplitude of the carrier wave. The resulting
signal contains both the upper and lower sidebands, each containing a copy of the original
modulating signal, as well as the original carrier frequency. However, the carrier frequency is
suppressed or removed, resulting in less efficient use of the transmitted power.
Page 31 of 70
2. Single-Sideband Suppressed Carrier (SSB-SC): This type of AM modulation method eliminates
one of the sidebands and the carrier frequency from the modulated signal, resulting in more
efficient use of the transmitted power. The resulting signal contains only one sideband, either the
upper or lower sideband, depending on the method used. This type of modulation is commonly
used in voice communications, as it provides a higher signal-to-noise ratio.
3. Vestigial Sideband (VSB): This type of AM modulation method is a combination of DSB-SC and
SSB-SC. It involves removing a portion of the unwanted sideband and leaving a "vestige" or
remnant of it. This allows for more efficient use of the transmitted power while still maintaining a
certain level of compatibility with the DSB-SC receiver. VSB is commonly used in television
broadcasting.
AM is commonly used in AM radio broadcasting and marine communication. One of the main
advantages of AM is its robustness against noise and interference, which makes it suitable for use in harsh
environments. However, one of the main disadvantages of AM is its limited bandwidth efficiency, which
can be a problem in systems where bandwidth is limited, such as satellite communication.
In summary, Amplitude Modulation (AM) is a method of conveying a baseband message signal over a
higher frequency carrier signal by varying the amplitude of the carrier signal in proportion to the baseband
signal. It has two types of AM, DSB, and SSB. AM is commonly used in AM radio broadcasting and
marine communication; it is robust against noise and interference but has a limited bandwidth efficiency.
Example 1:
clc;clear
% Define the sampling frequency and time vector
fs = 1000;
t = 0:1/fs:1;
% Generate modulating signal
m = sin(2*pi*5*t);
% Generate carrier signal
c = cos(2*pi*100*t);
% Modulate the carrier signal using the ammod function
y = ammod(m,100,fs,0);
% Plot the signals in the time domain
figure
subplot(3,1,1);
plot(t,m);
title('Modulating Signal');
subplot(3,1,2);
plot(t,c);
title('Carrier Signal');
subplot(3,1,3);
plot(t,y);
title('Modulated Signal');
% Perform FFT on the signals
Y_m = fft(m);
Y_c = fft(c);
Y_y = fft(y);
% Plot the signals in the frequency domain
figure
subplot(3,1,1);
plot(abs(Y_m));
title('FFT of Modulating Signal');
subplot(3,1,2);
plot(abs(Y_c));
title('FFT of Carrier Signal');
subplot(3,1,3);
plot(abs(Y_y)); Page 32 of 70
title('FFT of Modulated Signal');
% Plot the demodulated signal in the frequency domain
subplot(2,1,2);
plot(abs(Y_demod));
title('FFT of Demodulated Signal');
% Demodulation using the amdemod function
y_demod = amdemod(y,100,fs,0);
% Plot the demodulated signal in the time domain
figure
subplot(2,1,1);
plot(t,y_demod);
title('Demodulated Signal');
% Perform FFT on the demodulated signal
Y_demod = fft(y_demod);
This code is an example of how to generate and analyze an amplitude-modulated (AM) signal using
MATLAB.
The code performs the following steps:
1. The first step is to clear the command window and any existing variables in the workspace by
using the "clc" and "clear" commands.
2. The next step is to define the sampling frequency and time vector. The sampling frequency is set
to 1000 Hz and the time vector is set to start from 0 to 1 second, sampled at the rate of 1000
samples per second.
3. The next step is to generate a modulating signal. A sinusoidal signal with a frequency of 5 Hz is
generated over the time vector defined earlier. This will be the signal that will be used to modulate
the carrier signal.
4. The next step is to generate a carrier signal. A cosine signal with a frequency of 100 Hz is generated
over the time vector defined earlier. This will be the signal that will be modulated by the
modulating signal.
5. The next step is to modulate the carrier signal using the "ammod" function. The "ammod" function
modulates the carrier signal with the modulating signal, resulting in an amplitude-modulated
signal. The carrier frequency is set to 100 Hz, the sampling frequency is set to 1000 Hz, and the
modulation index is set to 0.
6. The next step is to plot the signals in the time domain. The modulating signal, carrier signal, and
modulated signal are plotted using the "plot" function.
7. The next step is to perform a fast Fourier transform (FFT) on the signals. The FFT of the
modulating signal, carrier signal, and modulated signal are calculated using the "fft" function.
8. The next step is to plot the signals in the frequency domain. The magnitude of the FFT of the
modulating signal, carrier signal, and modulated signal are plotted using the "plot" function.
9. The next step is to demodulate the modulated signal using the "amdemod" function. The "amdem
od" function demodulates the modulated signal, resulting in the original modulating signal. The
carrier frequency is set to 100 Hz, the sampling frequency is set to 1000 Hz, and the modulation
index is set to 0.
10. The next step is to plot the demodulated signal in the time domain. The demodulated signal is
plotted using the "plot" function.
Page 33 of 70
11. The last step is to perform a fast Fourier transform (FFT) on the demodulated signal. The FFT of
the demodulated signal is calculated using the "fft" function.
12. The last step is to plot the demodulated signal in the frequency domain. The magnitude of the FFT
of the demodulated signal is plotted using the "plot" function
In summary, this code generates an amplitude-modulated (AM) signal by modulating a sinusoidal
modulating signal with a carrier signal. The modulated signal is then demodulated to recover the original
modulating signal. The code also plots the signals in the time and frequency domain and uses the "ammod"
and "amdemod" functions to modulate and demodulate the signals respectively.
It is worth noting that the example in this code is a basic one, and some other variables and
parameters can be adjusted and optimized depending on the specific application and scenario. For
example, the modulation index, carrier frequency, and sampling frequency can be adjusted to change the
characteristics of the modulated signal. Also, different types of modulating and carrier signals can be used,
such as a square wave or sawtooth wave.
Additionally, the code also shows how to visualize the signals in the time and frequency domain using the
"plot" and "fft" functions. Understanding the time-domain and frequency-domain representation of signals
is important in communication systems as it can provide insight into the characteristics of the signal, such
as its frequency content, harmonic distortion, and noise.
In conclusion, this code is an example of how to generate and analyze an amplitude-modulated (AM)
signal using MATLAB. It shows the basic steps of modulating and demodulating a signal, as well as
visualizing the signals in the time and frequency domain. It serves as a starting point for further
experimentation and optimization in communication systems and also helps in understanding the
characteristics of signals.
Page 34 of 70
Page 35 of 70
Page 36 of 70
Example 2: AM modulation (DSB-SC) (without MATLAB built-in function) :
clc;clear;clf;close all
% Define the sampling frequency and time vector
fs = 1000;
t = 0:1/fs:1;
% Generate modulating signal
m = sin(2*pi*5*t);
fc=100;
% Generate carrier signal
c = cos(2*pi*100*t);
% Modulate the carrier signal
y = m.*c;
% Perform Demodulation
y_demod = y.*c;
% Design a low-pass filter
N = 5;
[b,a] = butter(N,fc*2/fs);
% Apply the low-pass filter to the demodulated signal
y_filtered = filter(b,a,y_demod);
% Plot the original modulating signal in the time domain
figure
subplot(3,2,1);
plot(t,m);
title('Modulating Signal');
% Perform FFT on the modulating signal
Y_m = fft(m);
% Plot the modulating signal in the frequency domain
subplot(3,2,2);
plot(abs(Y_m));
title('FFT of Modulating Signal');
% Plot the carrier signal in the time domain
subplot(3,2,3);
plot(t,c);
title('Carrier Signal');
% Perform FFT on the carrier signal
Y_c = fft(c);
% Plot the carrier signal in the frequency domain
subplot(3,2,4);
plot(abs(Y_c));
title('FFT of Carrier Signal');
% Plot the modulated signal in the time domain
subplot(3,2,5);
plot(t,y);
title('Modulated Signal');
% Perform FFT on the modulated signal
Y_y = fft(y);
% Plot the modulated signal in the frequency domain
subplot(3,2,6);
plot(abs(Y_y));
title('FFT of Modulated Signal');
% Plot the demodulated signal in the time domain
figure
subplot(2,2,1);
plot(t,y_demod);
title('Demodulated Signal');
% Perform FFT on the demodulated signal
Y_demod = fft(y_demod);
% Plot the demodulated signal in the frequency domain
subplot(2,2,2);
plot(abs(Y_demod));
title('FFT of Demodulated Signal');
% Plot the filtered demodulated signal in the time domain
subplot(2,2,3); Page 37 of 70
plot(t,y_filtered);
title('Filtered Demodulated Signal');
% Perform FFT on the filtered demodulated signal
Y_filtered = fft(y_filtered);
% Plot the filtered demodulated signal in the frequency domain
% Plot the filtered demodulated signal in the time domain
subplot(2,2,3);
plot(t,y_filtered);
title('Filtered Demodulated Signal');
% Perform FFT on the filtered demodulated signal
Y_filtered = fft(y_filtered);
% Plot the filtered demodulated signal in the frequency domain
subplot(2,2,4);
plot(abs(Y_filtered));
title('FFT of Filtered Demodulated Signal');
This code is an example of how to demodulate an amplitude-modulated (AM) signal using a low-pass
filter in MATLAB. The code performs the following steps:
1. The first step is to clear the command window and any existing variables in the workspace by
using the "clc", "clear", "clf" and "close all" commands.
2. The next step is to define the sampling frequency and time vector. The sampling frequency is set
to 1000 Hz and the time vector is set to start from 0 to 1 second, sampled at the rate of 1000
samples per second.
3. The next step is to generate a modulating signal. A sinusoidal signal with a frequency of 5 Hz is
generated over the time vector defined earlier. This will be the signal that will be used to modulate
the carrier signal.
4. The next step is to generate a carrier signal. A cosine signal with a frequency of 100 Hz is generated
over the time vector defined earlier. This will be the signal that will be modulated by the
modulating signal.
5. The next step is to modulate the carrier signal by multiplying the modulating signal with the carrier
signal. This results in an amplitude-modulated signal.
6. The next step is to perform demodulation by multiplying the modulated signal with the carrier
signal.
7. The next step is to design a low-pass filter. In this case, the filter order is set to 5, and the cutoff
frequency is set to half of the sampling frequency (fc*2/fs).
8. The next step is to apply the low-pass filter to the demodulated signal using the "filter" function.
9. The next step is to plot the original modulating signal, carrier signal, modulated signal, and
demodulated signal in the time domain and frequency domain. The modulating signal, carrier
signal, modulated signal, and demodulated signal are plotted using the "plot" function. The FFT
of the modulating signal, carrier signal, modulated signal, and demodulated signal are calculated
using the "fft" function and plotted using the "plot" function.
10. The next step is to plot the filtered demodulated signal in the time domain and frequency domain.
The filtered demodulated signal is plotted using the "plot" function. The FFT of the filtered
demodulated signal is calculated using the "fft" function and plotted using the "plot" function.
In summary, this code demodulates an amplitude-modulated (AM) signal by multiplying the modulated
signal with the carrier signal. A low-pass filter is then applied to the demodulated signal to remove the
high-frequency components. The code also plots the signals in the time and frequency domain and uses
the "filter" function to filter the demodulated signal. The use of the low-pass filter helps in isolating the
modulating signal from the carrier signal, which is important in communication systems as it can provide
insight into the characteristics of the signal.
Page 38 of 70
Page 39 of 70
Example 3 : AM SSB-SC modulation/demodulation
clc;clear all;
% Define the message signal
fs = 10000; % sample rate
t = 0:1/fs:1; % time vector
f_m = 5; % frequency of message signal
m = cos(2*pi*f_m*t); % message signal
subplot(3,1,2);
plot(fftshift(abs(fft(y_mod))));
title('SSB modulated signal');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
subplot(3,1,3);
plot(fftshift(abs(fft(y_demod))));
title('SSB demodulated signal');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
In this script, a message signal (m) is defined with a frequency of 5 Hz and a sample rate of 10000 Hz. A
carrier signal (f_c) with a frequency of 50 Hz is also defined. The message signal is then modulated using
Page 40 of 70
the ssbmod function with the carrier signal to produce the SSB modulated signal (y_mod). The ssbdemod
function is then used to demodulate the modulated signal and produce the demodulated signal (y_demod).
The time domain and frequency domain plots of the message signal, modulated signal, and demodulated
signal are then plotted using the subplot and plot functions.
Page 41 of 70
5.3 FM MODULATION
Frequency Modulation (FM) is a type of modulation in which the frequency of the carrier signal is
varied in proportion to the amplitude of the modulating signal. In contrast to Amplitude Modulation (AM),
where the amplitude of the carrier signal is varied in proportion to the amplitude of the modulating signal.
FM has several advantages over AM, some of them are:
1. Improved signal-to-noise ratio: FM is less sensitive to noise and interference than AM, which
makes it more resistant to noise and interference.
2. Better sound quality: FM provides better sound quality than AM because it is less affected by noise
and distortion.
3. Greater dynamic range: FM can transmit signals with a wider dynamic range than AM, which
allows for a greater range of volume levels.
4. Greater immunity to fading: FM is less affected by fading caused by atmospheric conditions than
AM, which makes it more reliable over long distances.
5. Greater efficiency: FM is more efficient than AM because it uses less power to transmit the same
amount of information.
However, FM also has some disadvantages:
1. Greater bandwidth requirements: FM requires a larger bandwidth than AM, which can be a
limitation in some situations.
2. More complex: FM is more complex to generate, demodulate, and process than AM, which can
make it more difficult and expensive to implement.
3. Greater sensitivity to frequency drift: FM is more sensitive to frequency drift than AM, which can
make it more difficult to maintain a stable signal.
In conclusion, FM is a type of modulation that varies the frequency of the carrier signal in proportion to
the amplitude of the modulating signal. It has several advantages over AM, such as improved signal-to-
noise ratio, better sound quality, greater dynamic range, greater immunity to fading, and greater efficiency.
However, FM also has some disadvantages, such as greater bandwidth requirements, more complexity,
and greater sensitivity to frequency drift.
Page 42 of 70
5.4 Fm Modulation/Demodulation example:
clc;clear all
% Define the message signal
fs = 10000; % sample rate
t = 0:1/fs:1; % time vector
f_m = 5; % frequency of message signal
m = cos(2*pi*f_m*t); % message signal
% Define the carrier signal
f_c = 50; % frequency of carrier signal
% Define the modulation index
beta = 0.5;
% Perform FM modulation
y_mod = fmmod(m,f_c,fs,beta);
% Perform FM demodulation
y_demod = fmdemod(y_mod,f_c,fs,beta);
% Plot the signals in time domain
figure;
subplot(3,1,1);
plot(t,m);
title('Message signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t,y_mod);
title('FM modulated signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t,y_demod);
title('FM demodulated signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Plot the signals in frequency domain
figure;
subplot(3,1,1);
plot(fftshift(abs(fft(m))));
title('Message signal');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
subplot(3,1,2);
plot(fftshift(abs(fft(y_mod))));
title('FM modulated signal');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
subplot(3,1,3);
plot(fftshift(abs(fft(y_demod))));
title('FM demodulated signal');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
This code is demonstrating an example of Frequency Modulation (FM) using MATLAB. It starts by
defining the message signal, carrier signal, and modulation index.
1. First, it sets the sampling frequency 'fs' and the time vector 't' and generates the message signal by
creating a cosine wave with the frequency of message signal 'f_m' and 't'.
2. Then, it sets the frequency of carrier signal 'f_c' and modulation index 'beta'.
Page 43 of 70
3. Next, it uses the 'fmmod' function to modulate the message signal 'm' using the carrier signal 'f_c'
with the sample rate 'fs' and the modulation index 'beta'. The output of this step is the FM-
modulated signal 'y_mod'.
4. Then it uses the 'fmdemod' function to demodulate the FM modulated signal 'y_mod' using the
carrier signal 'f_c' with the sample rate 'fs' and the modulation index 'beta'. The output of this step
is the demodulated signal 'y_demod'
5. Next, it plots the original message signal, FM modulated signal, and demodulated signal in the
time domain, using the 'plot' function.
6. Finally, it plots the original message signal, FM modulated signal, and demodulated signal in the
frequency domain, using the 'fftshift' and 'fft' functions to shift the frequency spectrum and
calculate the FFT respectively.
This code demonstrates how to modulate and demodulate a message signal using FM, and how to visualize
the original and modulated signals in both time and frequency domains. This is a good way of
understanding the concept of FM modulation and how it differs from AM modulation.
Page 44 of 70
clc;clear;close all
fs = 1000;
fc = 200;
t = (0:1/fs:0.1)';
x = sin(2*pi*30*t)+2*sin(2*pi*60*t);
fDev = 50;
int_x = cumsum(x)/fs;
xfm = cos(2*pi*fc*t).*cos(2*pi*fDev*int_x)-
sin(2*pi*fc*t).*sin(2*pi*fDev*int_x) ;
xi=cos(2*pi*fDev*int_x);
xq=sin(2*pi*fDev*int_x) ;
t2 = (0:1/fs:((size(xfm,1)-1)/fs))';
t2 = t2(:,ones(1,size(xfm,2)));
xfmq = hilbert(xfm).*exp(-j*2*pi*fc*t2);
z = (1/(2*pi*fDev))*[zeros(1,size(xfmq,2));
diff(unwrap(angle(xfmq)))*fs];
figure(1)
subplot(211)
plot(t,x)
subplot(212)
plot(t,xfm)
figure(2);
plot(t,x,'c',t2,z,'b--');
xlabel('time ');
ylabel('amplitude');
legend('Original Signal','Demodulated Signal');grid on
Page 45 of 70
5.5 PM MODULATION
Phase Modulation (PM) is a method of modulating a carrier signal in which the phase of the carrier
signal is varied in accordance with the amplitude of the message signal. In PM, the phase angle of the
carrier signal is varied in proportion to the amplitude of the message signal. This results in a modulated
signal whose phase is continuously changing with respect to the message signal.
The advantages of PM include its ability to provide a constant envelope, which allows for efficient
power amplification, as well as its ability to avoid detection by amplitude-sensitive jamming signals.
Additionally, PM is less affected by non-linearities in the transmission channel and is less susceptible to
phase noise.
Disadvantages of PM include its higher bandwidth requirements compared to other modulation
techniques, as well as the increased complexity of demodulation. Additionally, the phase of the PM signal
can drift over time, leading to decreased signal quality.
5.6 PM Modulation/demodulation EXAMPLE:
clc;clear all
% Define the message signal
fs = 10000; % sample rate
t = 0:1/fs:1; % time vector
f_m = 5; % frequency of message signal
m = cos(2*pi*f_m*t); % message signal
% Define the carrier signal
f_c = 50; % frequency of carrier signal
% Define the modulation index
beta = 0.5;
% Perform PM modulation
y_mod = pmmod(m,f_c,fs,beta);
% Perform PM demodulation
y_demod = pmdemod(y_mod,f_c,fs,beta);
% Plot the signals in time domain
figure;
subplot(3,1,1);
plot(t,m);
title('Message signal');xlabel('Time (s)');ylabel('Amplitude');
subplot(3,1,2);
plot(t,y_mod);
title('PM modulated signal');xlabel('Time (s)');ylabel('Amplitude');
subplot(3,1,3);
plot(t,y_demod);
title('PM demodulated signal');xlabel('Time (s)');ylabel('Amplitude');
% Plot the signals in frequency domain
figure;
subplot(3,1,1);
plot(fftshift(abs(fft(m))));
title('Message signal');xlabel('Frequency (Hz)');ylabel('Amplitude');
subplot(3,1,2);
plot(fftshift(abs(fft(y_mod))));
title('PM modulated signal');xlabel('Frequency (Hz)');ylabel('Amplitude');
subplot(3,1,3);
plot(fftshift(abs(fft(y_demod))));
title('PM demodulated signal');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
Page 46 of 70
This code is a MATLAB script that demonstrates the process of Phase Modulation (PM) modulation and
demodulation using built-in functions pmmod and pmdemod.
The code starts by defining the sample rate (fs) and the time vector (t). It then defines the frequency of the
message signal (f_m) and creates the message signal by taking the cosine of 2π times the message
frequency multiplied by the time vector.
The code then defines the frequency of the carrier signal (f_c) and the modulation index (beta). Using the
pmmod function, the message signal is modulated onto the carrier signal, creating the PM-modulated
signal (y_mod). Using the pmdemod function, the PM modulated signal is demodulated to recover the
original message signal (y_demod).
The code then plots the message signal, PM modulated signal, and PM demodulated signal in both the
time domain and frequency domain using the plot function and fft function. It also includes labeled x and
y axes and titles for each subplot.
Page 47 of 70
Page 48 of 70
6 Sampling and Quantization in MATLAB
6.1 Overview of sampling types
Sampling is the process of converting a continuous time signal into a discrete time signal by
measuring the signal's amplitude at regular intervals of time. There are two types of sampling techniques:
natural sampling and flat top sampling.
Natural sampling, also known as impulse sampling, is the process of measuring the signal's
amplitude at the instants of time when the signal crosses zero. The advantages of natural sampling are its
simplicity and the fact that it preserves the signal's original shape. However, it has the disadvantage of
producing significant signal distortion due to the presence of high-frequency components in the signal.
Flat top sampling, also known as gate sampling, is the process of measuring the signal's amplitude
at the instants of time when the signal is inside a specific time window, also known as the gate. The
advantages of flat top sampling are that it reduces signal distortion, and it also reduces the amount of noise
that is present in the signal. However, it has the disadvantage of requiring more complex hardware and
software to implement.
In general, flat top sampling is preferred over natural sampling for high-quality signal processing
applications because it provides more accurate and reliable results.
Page 49 of 70
6.3 Quantization
Quantization is the process of mapping a continuous analog signal to a discrete digital signal. It is a
fundamental step in the process of converting an analog signal to a digital signal, which is necessary for
digital signal processing and digital communications.
During quantization, the continuous amplitude values of the analog signal are divided into a finite
number of levels or bins. Each bin corresponds to a specific digital value, and the analog signal's amplitude
is approximated to the closest digital value in the corresponding bin. This process results in a loss of
information, known as quantization error. The number of levels or bins used in quantization is known as
the quantization resolution.
The effects of quantization on signals depend on the number of levels used and the amplitude range
of the signal. A higher number of levels and a larger amplitude range result in a smaller quantization error
and a higher signal-to-noise ratio (SNR). However, a higher number of levels also results in a higher bit
rate and larger storage requirements. In contrast, a lower number of levels and a smaller amplitude range
result in a larger quantization error and a lower SNR.
Overall, quantization is a trade-off between the accuracy of the digital signal and the bit rate and
storage requirements.
Page 50 of 70
6.4 Examples of quantization & quantization error using MATLAB
subplot(3,1,2);
stairs(t,x_quant,'r');
%stem(t,x_quant,'r');
title('Quantized signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t,e);
title('Quantization error');
xlabel('Time (s)');
ylabel('Amplitude');
Page 51 of 70
7 Digital modulation techniques
Digital modulation techniques are methods used to encode digital information onto an analog carrier
signal. These techniques are used to transmit digital data over a distance without distortion. The main
digital modulation techniques are Amplitude Shift Keying (ASK), Frequency Shift Keying (FSK), Phase
Shift Keying (PSK), and Quadrature Phase Shift Keying (QPSK).
ASK is a simple digital modulation technique that varies the amplitude of the carrier signal to
represent the digital data. It is a form of on-off keying, where the amplitude of the carrier signal is either
high or low, representing binary 1 or 0.
FSK is a digital modulation technique that varies the frequency of the carrier signal to represent the
digital data. It is a form of frequency-shift keying, where the frequency of the carrier signal is shifted
between two or more discrete frequencies, representing binary 1 or 0.
PSK is a digital modulation technique that varies the phase of the carrier signal to represent the digital
data. It is a form of phase-shift keying, where the phase of the carrier signal is shifted between two or
more discrete phase angles, representing binary 1 or 0.
QPSK is a digital modulation technique that combines phase and amplitude modulation to represent
digital data. It is a form of quadrature phase-shift keying, where the phase of the carrier signal is shifted
between four discrete phase angles, representing two bits of data.
Each of these digital modulation techniques has its advantages and disadvantages. ASK is simple to
implement and has low power consumption, but it is sensitive to noise and has a low data rate. FSK is also
simple to implement and has a moderate data rate, but it is also sensitive to noise. PSK and QPSK have a
higher data rate and are less sensitive to noise, but they are more complex to implement.
Other digital modulation techniques include:
• Quadrature Amplitude Modulation (QAM)
• Orthogonal Frequency Division Multiplexing (OFDM)
• Code Division Multiple Access (CDMA)
• etc.
• Each of these techniques have their own advantages and disadvantages and are used in different
communication scenarios depending on the requirements of the system.
Page 52 of 70
Advantages:
1. Simple to implement and understand.
2. Requires low power and bandwidth.
3. Has a high tolerance to noise and interference.
Disadvantages:
1. Has a low spectral efficiency, i.e., the amount of data that can be transmitted per unit bandwidth
is limited.
2. Is vulnerable to fading and interference, since the amplitude of the carrier wave is used to transmit
information.
3. Requires precise amplitude control, which may be difficult to achieve in practice.
Applications:
1. Remote control systems, such as those used in garage door openers and TV remote controls.
2. Wireless communication systems, such as those used in low-data-rate wireless personal area
networks (WPANs) and home automation systems.
3. RFID systems, used for tracking and identification purposes.
4. Satellite communication systems, for low-speed data transmission.
%>>>>>>>>> MATLAB code for binary ASK modulation and de-modulation >>>>>>>%
clc; clear all; close all;
x=[ 1 0 0 1 1 0 1]; % Binary Information
bp=.000001; % bit period
disp(' Binary information at Trans mitter :');
disp(x);
%XX representation of transmitting binary information as digital signal XXX
bit=[];
for n=1:1:length(x)
if (x(n)==1)
se=ones(1,100);
else
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');xlabel(' time(sec)');
title('transmitting information as digital signal');
%XXXXXXXXXXXXXXXXXXXXXXX Binary-ASK modulation XXXXXXXXXXXXXXXXXXXXXXXXXXX%
A1=10; % Amplitude of carrier signal for information 1
A2=5; % Amplitude of carrier signal for information 0
br=1/bp; % bit rate
f=br*10; % carrier frequency
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A1*cos(2*pi*f*t2);
else
y=A2*cos(2*pi*f*t2);
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');ylabel('amplitude(volt)'); Page 53 of 70
title('waveform for binary ASK modulation coresponding binary information');
mn=[mn a];
%XXXXXXXXXXXXXXXXXXXX Binary ASK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mn=[];
for n=ss:ss:length(m)
t=bp/99:bp/99:bp;
y=cos(2*pi*f*t); % carrier siignal
mm=y.*m((n-(ss-1)):n);
t4=bp/99:bp/99:bp;
z=trapz(t4,mm) % intregation
zz=round((2*z/bp))
if(zz>7.5) % logic level = (A1+A2)/2=7.5
a=1;
else
a=0;
end
mn=[mn a];
end
disp(' Binary information at Reciver :');
disp(mn);
%XXXXX Representation of binary information as digital signal which achived
%after ASK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bit=[];
for n=1:length(mn);
if (mn(n)==1)
se=ones(1,100);
else
se=zeros(1,100);
end
bit=[bit se];
end
t4=bp/100:bp/100:100*length(mn)*(bp/100);
subplot(3,1,3)
plot(t4,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(mn) -.5 1.5]);
ylabel('amplitude(volt)');xlabel(' time(sec)');
title('recived information as digital signal after binary ASK demodulation');
%>>>>>>>>>>>>>>>>>>>>>>>>>> end of program >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>%
This code is an implementation of Amplitude Shift Keying (ASK) modulation and demodulation in
MATLAB. It generates a binary signal, modulates it using ASK, and then demodulates it to obtain the
original binary signal. It includes the following steps:
Page 54 of 70
1. Generating a binary signal "x" and displaying it.
2. Representing the binary signal as a digital signal by plotting it in the time domain.
3. Modulating the binary signal by multiplying it with a carrier signal of different amplitude (A1 or
A2) depending on the value of the binary signal.
4. Plotting the modulated signal in the time domain.
5. Demodulating the modulated signal by multiplying it with the carrier signal again and integrating
it over the bit period.
6. Comparing the integrated value with a threshold value (7.5) to obtain the original binary signal.
7. Displaying the original binary signal and plotting it in the time domain.
Disadvantages:
1. Sensitive to phase noise
2. Not as spectrally efficient as other digital modulation techniques like PSK
Applications:
1. Wireless communication systems such as RFID, Zigbee, and Bluetooth
2. Remote control systems, including those used in industrial, automotive, and medical industries
3. Telemetry systems for transmitting data from remote sensors and instruments
4. Satellite communication systems for transmitting digital data
5. Radio communication systems for transmitting digital data over long distances.
Page 55 of 70
%>>>>>>>>> MATLAB code for binary FSK modulation and de-modulation >>>>>>>%
x=[ 1 0 0 1 1 0 1]; % Binary Information
bp=.000001; % bit period
disp(' Binary information at Transmitter :');disp(x);
%XX representation of transmitting binary information as digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');xlabel(' time(sec)');
title('transmitting information as digital signal');
%XXXXXXXXXXXXXXXXXXXXXXX Binary-FSK modulation XXXXXXXXXXXXXXXXXXXXXXXXXXX%
A=5; % Amplitude of carrier signal
br=1/bp; % bit rate
f1=br*8; % carrier frequency for information as 1
f2=br*2; % carrier frequency for information as 0
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A*cos(2*pi*f1*t2);
else
y=A*cos(2*pi*f2*t2);
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');ylabel('amplitude(volt)');
title('waveform for binary FSK modulation coresponding binary information');
%XXXXXXXXXXXXXXXXXXXX Binary FSK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mn=[];
for n=ss:ss:length(m)
t=bp/99:bp/99:bp;
y1=cos(2*pi*f1*t); % carrier siignal for information 1
y2=cos(2*pi*f2*t); % carrier siignal for information 0
mm=y1.*m((n-(ss-1)):n);
mmm=y2.*m((n-(ss-1)):n);
t4=bp/99:bp/99:bp;
z1=trapz(t4,mm) % intregation
z2=trapz(t4,mmm) % intregation
zz1=round(2*z1/bp)
zz2= round(2*z2/bp)
if(zz1>A/2) % logic lavel= (0+A)/2 or (A+0)/2 or 2.5 ( in this case)
a=1;
else(zz2>A/2)
a=0;
end
mn=[mn a];
end
disp(' Binary information at Reciver :');disp(mn);
%Representation of binary information as digital signal which achieved %after demodulation X
bit=[];
for n=1:length(mn);
if mn(n)==1;
se=ones(1,100);
else mn(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t4=bp/100:bp/100:100*length(mn)*(bp/100);
subplot(3,1,3)
plot(t4,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(mn) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)'); Page 56 of 70
title('recived information as digital signal after binary FSK demodulation');
%>>>>>>>>>>>>>>>>>>>>>>>>>> end of program >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>%
7.3 Phase Shift Keying (PSK)
PSK is a type of digital modulation technique that represents digital data by varying the phase of a
reference carrier signal. In PSK, the information is conveyed by shifting the phase of the carrier signal
by 0 or 180 degrees for binary data (BPSK) or by specific phase shifts for multiple bits per symbol
(MPSK).
Advantages of PSK:
1. Robust against noise: PSK is less sensitive to noise compared to amplitude-based modulation
techniques, making it more suitable for noisy communication channels.
2. High Spectral Efficiency: PSK can transmit multiple bits per symbol, leading to a high spectral
efficiency.
3. Easy to implement: PSK is relatively simple to implement compared to other digital
modulation techniques, as it requires only phase shifts and not amplitude changes.
Disadvantages of PSK:
1. Sensitive to phase errors: PSK is more sensitive to phase errors compared to amplitude-based
modulation techniques, which can lead to errors in data transmission.
2. More complex receiver: PSK requires a more complex receiver compared to amplitude-based
modulation techniques, as it requires phase detection capabilities.
Applications of PSK:
1. Wireless communication systems: PSK is widely used in wireless communication systems
such as Bluetooth, Wi-Fi, and GPS.
Page 57 of 70
2. Satellite communication: PSK is used in satellite communication to transmit digital data from
one location to another.
3. Radio communication: PSK is used in radio communication for digital data transmission.
4. Optical communication: PSK is used in optical communication systems for high-speed data
transmission.
%>>>>>>>>> MATLAB code for binary PSK modulation and de-modulation >>>>>>>%
x=[ 1 0 0 1 1 0 1]; % Binary Information
bp=.000001; % bit period
disp(' Binary information at Trans mitter :');
disp(x);
%XX representation of transmitting binary information as digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');xlabel(' time(sec)');
title('transmitting information as digital signal');
%XXXXXXXXXXXXXXXXXXXXXXX Binary-PSK modulation XXXXXXXXXXXXXXXXXXXXXXXXXXX%
A=5; % Amplitude of carrier signal
br=1/bp; % bit rate
f=br*2; % carrier frequency
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A*cos(2*pi*f*t2);
else
y=A*cos(2*pi*f*t2+pi); %A*cos(2*pi*f*t+pi) means -A*cos(2*pi*f*t)
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');ylabel('amplitude(volt)');
title('waveform for binary PSK modulation corresponding binary information');
%XXXXXXXXXXXXXXXXXXXX Binary PSK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mn=[];
for n=ss:ss:length(m)
t=bp/99:bp/99:bp;
y=cos(2*pi*f*t); % carrier siignal
mm=y.*m((n-(ss-1)):n);
t4=bp/99:bp/99:bp;
z=trapz(t4,mm) % intregation
zz=round((2*z/bp))
if(zz>0) % logic level = (A+A)/2=0
%becouse A*cos(2*pi*f*t+pi) means -A*cos(2*pi*f*t)
a=1;
else
a=0;
end
mn=[mn a];
end
disp(' Binary information at Reciver :');
disp(mn);
Page 58 of 70
%XXXXX Representation of binary information as digital signal which achived
%after PSK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bit=[];
for n=1:length(mn);
if mn(n)==1;
se=ones(1,100);
else mn(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t4=bp/100:bp/100:100*length(mn)*(bp/100);
subplot(3,1,3)
plot(t4,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(mn) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('recived information as digital signal after binary PSK demodulation');
%>>>>>>>>>>>>>>>>>>>>>>>>>> end of program >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>%
Page 59 of 70
2. Improved signal to noise ratio: QAM provides an improved signal to noise ratio compared to
AM, leading to better signal quality.
3. Increased spectral efficiency: QAM modulates multiple bits per symbol, resulting in higher
spectral efficiency compared to other modulation techniques.
4. Robustness: QAM is robust against channel fading and multipath fading, providing reliable
signal quality in noisy environments.
Disadvantages of QAM:
1. Complexity: QAM requires more complex hardware and signal processing compared to other
modulation techniques, leading to higher costs.
2. Vulnerability to Interference: QAM is vulnerable to interference, making it less suitable for
environments with high levels of interference.
Applications of QAM:
1. Digital television: QAM is used in digital television systems to transmit high-definition video
and audio.
2. Wireless communications: QAM is used in wireless communication systems to transmit large
amounts of data over limited bandwidths.
3. Broadband networks: QAM is used in broadband networks to transmit data, voice, and video
over cable and fiber optic networks.
4. Data communication: QAM is used in data communication systems to transmit large amounts
of data over limited bandwidths.
Page 60 of 70
8.1 Summary of key concepts covered in the lab manual:
• Overview of analog and digital communication systems
• Comparison of analog and digital signals
• Explanation of modulation and its importance
• Applications of digital and analog communication systems
• Introduction to MATLAB and its use in communication systems
• Signal analysis and generation in MATLAB
• Analog modulation techniques (AM, FM, PM) and their implementation using MATLAB
• Digital modulation techniques (ASK, FSK, PSK, QAM) and their implementation using
MATLAB.
Page 61 of 70
Choose the correct answer for the following questions:
1. What is the primary purpose of using MATLAB in communication systems?
a) To generate basic signals
b) To analyze signals in the time-domain
c) To analyze signals in the frequency-domain
d) All of the above
2. Which of the following is not a basic signal that can be generated in MATLAB?
a) Sine wave
b) Square wave
c) Triangle wave
d) Diamond wave
3. What is the command used in MATLAB to generate a sine wave with a frequency of 10Hz and
a amplitude of 2?
a) sin(2pi10t)
b) sine(2pi10t)
c) sin(10t)
d) sin(2pi10t, 2)
4. How can you superimpose two signals in MATLAB?
a) By adding the two signals together
b) By multiplying the two signals together
c) By subtracting the two signals
d) By using the command ‘superimpose’
5. What is the purpose of using noise generators in MATLAB?
a) To generate random noise in a signal
b) To analyze the effects of noise on a signal
c) Both a and b
d) None of the above
6. What is the command used to perform a time-domain analysis in MATLAB?
a) signalplot
Page 62 of 70
b) timeplot
c) plot
d) fft
7. What is the command used to perform a frequency-domain analysis in MATLAB?
a) signalplot
b) timeplot
c) plot
d) fft
8. What is the command used to generate a square wave in MATLAB?
a) square(2pi10t)
b) sqwave(2pi10t)
c) sqrt(2pi10t)
d) squarewave(2pi10t)
9. What is the command used to generate a sawtooth wave in MATLAB?
a) sawtooth()
b) sine()
c) square()
d) triangle()
10. What is the difference between analog and digital signals?
a) Analog signals are continuous while digital signals are discrete
b) Analog signals are discrete while digital signals are continuous
c) Analog signals are always a sine wave while digital signals are always square
d) Analog signals are always a square wave while digital signals are always a sine wave
11. What is the main purpose of modulation in communication systems?
a) To increase the amplitude of a signal
b) To increase the frequency of a signal
c) To increase the resistance of a signal
d) To make the signal suitable for transmission over a distance
Page 63 of 70
12. What is the primary use of MATLAB in communication systems?
a) Signal generation
b) Signal analysis
c) Data compression
d) All of the above
13. What is the primary difference between DSB-SC and SSB-SC in AM modulation?
a) DSB-SC uses two sidebands while SSB-SC uses only one
b) DSB-SC uses only one sideband while SSB-SC uses two
c) DSB-SC uses a suppressed carrier while SSB-SC does not
d) DSB-SC does not use a suppressed carrier while SSB-SC does
14. What is the purpose of flat top sampling in communication systems?
a) To improve the accuracy of the signal
b) To reduce the number of samples needed
c) To reduce the amount of noise in the signal
d) To create a more efficient modulation method
15. What is the difference between natural sampling and flat top sampling?
a) Natural sampling uses a sine wave while flat top uses a square wave
b) Natural sampling uses a square wave while flat top uses a sine wave
c) Natural sampling uses a low-pass filter while flat top does not
d) Natural sampling does not use a low-pass filter while flat top does
16. What is the effect of quantization on a signal?
a) It increases the amplitude of the signal
b) It increases the frequency of the signal
c) It introduces noise into the signal
d) It reduces the resolution of the signal
What is the primary advantage of ASK modulation over other digital modulation techniques?
a) It has a lower bit error rate
b) It has a higher bit rate
Page 64 of 70
c) It has a higher signal-to-noise ratio
d) It is more resistant to interference
17. What is the purpose of modulation in communication systems?
a. To convert analog signals into digital signals
b. To increase the frequency of a signal
c. To vary the characteristics of a carrier wave in accordance with the information-bearing signal
d. To decrease the frequency of a signal
18. What is the difference between analog and digital signals?
a. Analog signals are continuous while digital signals are discrete
b. Analog signals are discrete while digital signals are continuous
c. Analog signals are always louder than digital signals
d. Analog signals are always clearer than digital signals
19. What are the applications of digital and analog communication systems?
a. Television and radio broadcasting
b. Wireless communication
c. Telephone systems
d. All of the above
20. What is the use of MATLAB in communication systems?
a. Signal analysis
b. Signal generation
c. Modulation and demodulation
d. All of the above
21. What is the difference between time-domain analysis and frequency-domain analysis?
a. Time-domain analysis is used for analyzing the amplitude of a signal while frequency-domain
analysis is used for analyzing the frequency of a signal
b. Time-domain analysis is used for analyzing the frequency of a signal while frequency-domain
analysis is used for analyzing the amplitude of a signal
c. Time-domain analysis is used for analyzing the phase of a signal while frequency-domain
analysis is used for analyzing the frequency of a signal
Page 65 of 70
d. Time-domain analysis is used for analyzing the phase of a signal while frequency-domain
analysis is used for analyzing the amplitude of a signal
22. What is Amplitude Modulation (AM)?
a. A method of varying the amplitude of a carrier wave according to the information-bearing signal
b. A method of varying the frequency of a carrier wave according to the information-bearing signal
c. A method of varying the phase of a carrier wave according to the information-bearing signal
d. None of the above
23. What is the difference between Double-Sideband Suppressed Carrier (DSB-SC) and Single-
Sideband Suppressed Carrier (SSB-SC) modulation?
a. DSB-SC uses both sidebands while SSB-SC uses only one sideband
b. DSB-SC uses only one sideband while SSB-SC uses both sidebands
c. DSB-SC uses only the upper sideband while SSB-SC uses only the lower sideband
d. None of the above
24. What is the mathematical representation of a frequency modulated signal?
A) Acos(2πft)
B) Acos(2π(f0+kf)t)
C) Asin(2πft)
D) Asin(2π(f0+kf)t)
25. What is the main difference between Phase Modulation (PM) and Frequency Modulation
(FM)?
A. The modulating signal in FM is a frequency, while in PM it is a phase
B. The modulating signal in FM is a phase, while in PM it is a frequency
C. Both have the same modulating signal
D. PM uses analog signals while FM uses digital signals
26. Which type of sampling method ensures that there is no overlap between the samples?
A. Natural sampling
B. Flat top sampling
C. Random sampling
D. Pulse sampling
Page 66 of 70
27. How does quantization affect the signal-to-noise ratio?
A. It increases the signal-to-noise ratio
B. It decreases the signal-to-noise ratio
C. It has no effect on the signal-to-noise ratio
D. It depends on the type of quantization method used
28. Which modulation technique is used in the digital transmission of data?
A. Amplitude Modulation
B. Frequency Modulation
C. Phase Modulation
D. All of the above
29. What is the effect of increasing the number of levels in quantization?
A. The signal-to-quantization noise ratio will decrease
B. The signal-to-quantization noise ratio will increase
C. The signal-to-quantization noise ratio will remain the same
D. The signal-to-quantization noise ratio will fluctuate
30. Which of the following is not an analog modulation technique?
A. Amplitude Modulation (AM)
B. Frequency Modulation (FM)
C. Phase Modulation (PM)
D. Quadrature Amplitude Modulation (QAM)
31. What is the major disadvantage of natural sampling?
A. It produces high-frequency artifacts in the signal
B. It requires a high-frequency clock signal
C. It is more sensitive to noise and distortion
D. It is less efficient than other sampling methods
32. What is the main advantage of digital communication systems over analog communication
systems?
A) Increased signal clarity
B) Greater noise immunity
Page 67 of 70
C) Increased signal strength
D) All of the above
33. What is the basic principle behind Amplitude Shift Keying (ASK)?
A) The amplitude of the carrier wave is changed to represent the digital data
B) The frequency of the carrier wave is changed to represent the digital data
C) The phase of the carrier wave is changed to represent the digital data
D) None of the above
34. In ASK, what is the amplitude of the carrier wave when a "1" is being transmitted?
A) High
B) Low
C) Constant
D) Alternating
35. How is the digital data in ASK demodulation recovered?
A) By comparing the amplitude of the received signal to a threshold value
B) By comparing the frequency of the received signal to a threshold value
C) By comparing the phase of the received signal to a threshold value
D) None of the above
36. How does increasing the number of levels in ASK affect the bit error rate?
A) Increases the bit error rate
B) Decreases the bit error rate
C) Does not affect the bit error rate
D) None of the above.
37. How does increasing the bandwidth of the signal in ASK affect the bit error rate?
A) Increases the bit error rate
B) Decreases the bit error rate
C) Does not affect the bit error rate
D) None of the above.
38. Which of the following are the main types of digital modulation techniques?
A) Amplitude Shift Keying (ASK)
Page 68 of 70
B) Frequency Shift Keying (FSK)
C) Phase Shift Keying (PSK)
D) All of the above.
39. Which type of digital modulation technique is most resistant to noise?
A) Amplitude Shift Keying (ASK)
B) Frequency Shift Keying (FSK)
C) Phase Shift Keying (PSK)
D) Quadrature Amplitude Modulation (QAM)
40. Which type of digital modulation technique is most efficient in terms of bandwidth?
A) Amplitude Shift Keying (ASK)
B) Frequency Shift Keying (FSK)
C) Phase Shift Keying (PSK)
D) Quadrature Amplitude Modulation (QAM)
E) Quadrature Phase Shift Keying (QPSK)
41. What is the difference between FSK and PSK?
a) FSK uses amplitude modulation, while PSK uses frequency modulation
b) FSK uses frequency modulation, while PSK uses amplitude modulation
c) FSK uses phase modulation, while PSK uses amplitude modulation
d) FSK uses phase modulation, while PSK uses frequency modulation
42. How does FSK represent binary data?
a) By varying the frequency of the carrier signal
b) By varying the phase of the carrier signal
c) By varying the amplitude of the carrier signal
d) By combining the phase and frequency of the carrier signal
43. What is the advantage of using PSK over FSK?
a) PSK can transmit data faster than FSK
b) PSK is more resistant to noise than FSK
c) PSK uses less bandwidth than FSK
Page 69 of 70
d) PSK is easier to implement than FSK
44. How does PSK represent binary data?
a) By varying the frequency of the carrier signal
b) By varying the phase of the carrier signal
c) By varying the amplitude of the carrier signal
d) By combining the phase and frequency of the carrier signal
45. What is the main drawback of using FSK?
a) It requires a large bandwidth
b) It is sensitive to noise
c) It is difficult to implement
d) All of the above.
Page 70 of 70