DSP First Experiment
DSP First Experiment
THEORY: MATLAB stands for "MATrix LABoratory", which reflects its origins as a tool for matrix operations and linear
algebra. However, it has evolved into a much more powerful tool that supports a wide range of numerical and
computational tasks. It allows users to perform various computational tasks such as data analysis, signal processing, and
image and video processing. MATLAB also provides a variety of toolboxes that extend its capabilities for specific
application domains, such as control systems, statistics, and optimization.
MATLAB's programming language is designed to be easy to learn and use, and it supports a variety of programming
paradigms, including procedural, object-oriented, and functional programming. It also has a rich set of built-in functions
and commands, which can be used to perform common tasks and operations.
MATLAB's interactive environment allows users to enter commands and see immediate results, which makes it useful
for exploratory work and rapid prototyping. It also supports the creation of custom graphical user interfaces (GUIs) and
the development of standalone applications.
Overall, MATLAB is a powerful and versatile tool that has become an indispensable part of many scientific and
engineering workflows.
WINDOWS:
1. COMMAND WINDOW
The command window in MATLAB is a powerful
interactive interface that allows you to execute
commands, display and analyze data, and interact with
the MATLAB environment. It is the main window in
MATLAB, and it appears by default when you start
MATLAB.
You can use the command window to enter and execute
commands in MATLAB. This makes it a powerful tool for
exploring data, performing calculations, and testing code.
For example, you can use the command window to
create variables, define functions, load data from files,
and generate plots. The results of executed commands
are displayed in the command window, including any
error messages that may occur.
In addition to executing commands, the command
window also provides a number of other features that
make it a powerful tool for working with MATLAB. For example, the command history is stored in the command
window, allowing you to recall and execute previously executed commands. The command window also supports
command-line editing, which makes it easy to correct mistakes and modify previous commands. Another useful feature
of the command window is the ability to save commands and output to a file.
Overall, the command window in MATLAB is a powerful and flexible tool that is essential for working with MATLAB. It
allows you to interact with the MATLAB environment in a flexible and efficient manner, making it easier to perform data
analysis, modelling, and simulation tasks.
2. EDITOR WINDOW
3. FIGURE WINDOW
The Figure window in MATLAB is a graphical window that
is used to display plots, graphs, and other visualizations.
It is the primary output mechanism for creating
visualizations in MATLAB.
You can create a Figure window using the "figure"
command in MATLAB. Once you have created a Figure
window, you can use MATLAB commands to create and
modify visualizations. This might include commands to
plot data, create bar charts, or generate scatter plots.
The Figure window can display multiple plots
simultaneously, each in its own axis or subplot.
The Figure window provides many customization options
to modify the appearance of visualizations. For example,
you can change the colours and styles of lines, add labels and titles to the plot, and adjust the size and layout of the plot.
You can also add other graphical elements, such as text annotations, arrows, and shapes.
In addition to modifying the appearance of visualizations, the Figure window provides interactive tools to explore and
analyze data. For example, you can use the data cursor tool to view the values of individual data points, or use the zoom
and pan tools to focus on specific parts of a plot.
The Figure window also supports saving plots in a variety of formats, including JPEG, PNG, PDF, and MATLAB figure files.
This allows you to share your visualizations with others or to include them in reports or presentations.
Overall, the Figure window in MATLAB is a powerful and flexible tool for creating visualizations of data. It provides a
wide range of customization and interactive options that allow you to create professional-quality plots and graphs, and
is an essential tool for anyone working with data in MATLAB.
COMMANDS:
There are several types of commands that you can give in MATLAB.
The most common types of commands include:
2) Arithmetic commands: Used to perform mathematical operations on variables or values. For example, x + y or
sin(x).
3) Control flow commands: Used to control the flow of execution in a program. This includes commands like "if",
"for", "while", and "switch".
4) Input/output commands: Used to read or write data to and from files, or to interact with the user. For example,
input() or fprintf().
5) Graphics commands: Used to create plots and visualizations. This includes commands like plot(), scatter(), and
imshow().
6) Function commands: Used to create user-defined functions that can be called from other parts of a program.
For example, function [y] = myfunction(x).
7) System commands: Used to interact with the operating system, such as running external programs or accessing
system variables. This includes commands like system() or getenv().
These are just some of the most common types of commands that you can use in MATLAB. Depending on your specific
use case, there may be other types of commands that you need to use as well.
PLOTS:
MATLAB provides a wide variety of plot types for creating visualizations of data. Here are some of the most common
types of plots in MATLAB:
1. Line plots: These plots show data as a series of points connected by lines. The plot function is used to create line
plots in MATLAB.
2. Scatter plots: These plots show data as a collection of points, with each point representing a single observation.
The scatter function is used to create scatter plots in MATLAB.
3. Bar plots: These plots show data as bars of different heights, with each bar representing a category or group.
The bar function is used to create bar plots in MATLAB.
4. Histograms: These plots show the distribution of a set of values by grouping them into bins and counting the
number of values in each bin. The histogram function is used to create histograms in MATLAB.
5. Pie charts: These plots show the relative proportions of different categories in a dataset as wedges of a pie. The
pie function is used to create pie charts in MATLAB.
6. Heatmaps: These plots show the intensity of data values as a color map, with each color representing a
different range of values. The heatmap function is used to create heatmaps in MATLAB.
7. Contour plots: These plots show the contours of a function of two variables, with each contour representing a
particular level of the function. The contour function is used to create contour plots in MATLAB.
These are just a few examples of the types of plots that can be created in MATLAB. Depending on your specific needs,
there may be other plot types or variations of these plot types that you can use as well.
EXPERIMENT – 2
Signals can be of various types, including analog and digital signals. Analog signals are continuous-time signals that vary
continuously over time, while digital signals are discrete-time signals that take on only specific values at specific points
in time. Signals can also be periodic or non-periodic, deterministic or stochastic, and can be represented in various
forms such as sine waves, square waves, pulses, and more.
In communication systems, signals are often modified or processed to improve their quality or to extract information
from them. This can involve operations such as filtering, modulation, demodulation, and encoding/decoding. The choice
of signal processing techniques depends on the specific communication system and the nature of the signals being
transmitted.
SIGNALS:
1. SINE WAVE
A sine wave is a mathematical function that describes a smooth, repetitive oscillation. It has a shape that
resembles a wave, with peaks and valleys that repeat over a period of time. The mathematical equation for a
sine wave is y(t) = A sin(2πft + φ), where A is the amplitude of the wave, f is the frequency, t is time, and φ is the
phase shift.
CODE:
t = 0:0.01:2*pi;
% time values (from 0 to 2*pi, in steps of 0.01)
2. COSINE WAVE
A cosine wave is similar to a sine wave, but is shifted in phase by 90 degrees (or π/2 radians) relative to the sine
wave. The mathematical equation for a cosine wave is y(t) = A cos(2πft + φ).
CODE:
t = 0:0.01:2*pi; % time values (from 0 to 2*pi, in steps of 0.01)
y = 2*cos(2*t); % cosine wave values
CODE:
t = 0:0.01:5; % Generate time vector
A = 1; % Calculate exponential
wave
tau = 0.5;
y = A * exp(-t/tau);
CODE:
n = 0:9; % Generate unit signal
x = [zeros(1,4),1,zeros(1,5)];
CODE:
n = -10:10; % Define the range of values for signal
u = n >= 0; % Generate the unit step signal
stem(n,u); % Plot the signal using the stem function
xlabel('n');
ylabel('u[n]');
title('Unit Step Signal');
6. RAMP WAVE
In signal processing, a ramp signal is a type of signal that has linearly increasing or decreasing amplitude over
time. It is also known as a slope or linear signal. Mathematically, a ramp signal can be defined as:
ramp(t) = at + b
where a is the slope or rate of change of the signal, and b is the initial value of the signal at t = 0.
A ramp signal with a positive slope increases in amplitude over time, while a ramp signal with a negative slope
decreases in amplitude over time. The slope of the ramp signal determines the rate at which the amplitude
changes.
CODE:
t = 0:0.1:10; % Generate time vector
7. SINC WAVE
The sinc waveform is a periodic function that has a main lobe centered at x = 0 and smaller side lobes on either
side of the main lobe. The amplitude of the sinc waveform is highest at x = 0 and decreases as x moves away
from zero. The width of the main lobe and the amplitude of the side lobes depend on the length of the
waveform and the sampling rate used to generate it.
Formula for sinc signal is: sinc(x) = sin(x) / x
CODE:
clc
clear all
close all
t=-5:0.001:5;
w=-4*pi:0.01:4 pi;
for i=1:length (w)
xcw(i)=trapz (t, xct. *exp(-li*w(i).*t)); %fourier transform
end
plot(w, abs (xcw));
xlabel('w');
ylabel('absolute of sinc waveform');
grid on;
RESULT:
Basic signals used in signal processing such as sine, cosine, exp. signals were plotted on MATLAB.