Programs for digital signal processing. written using MATLAB
Pages
MATLAB program for step waveform generation
Program Code
n=0:5;y=[ones(1,6)];
stem (n,y);
xlabel ('Time');
ylabel ('Amplitude');
title ('Step Waveform');
grid on;
Output
Explanation of Program Code
clc;
It clears all input and
output from the Command Window display giving clean screen. It removes items
from workspace, freeing up system memory. After using clc, the scroll bar
cannot be used to see the history of functions, but still the up arrow can be
used to recall statements from the command history.
clear all;
It removes all variables from
the workspace. This frees up system memory.
close all;
It deletes all figures whose
handles are not hidden.
n=0:5;
This command creates vector
n.
Vector n is given by
n= [0 1
2 3 4 5]
Here vector n is used as x
axis.
y=[ones(1,6)];
This command generates step
waveform.
stem (n,y);
This command plots n versus
the columns of y as stems. . n and y must be vectors or matrices of the same
size. Additionally, n can be a row or a column vector and y a matrix with
length(n) rows.
This command makes step
waveform appear on the screen.
xlabel ('Time');
It labels the x-axis as 'Time'.
Each axes graphics object can have one label for
the x-, y-, and z-axis. The label appears beneath its respective axis in a
two-dimensional plot.
ylabel ('Amplitude');
It labels the y-axis as '
Amplitude. '
title ('Step Waveform');
It outputs the phrase 'Step Waveform' above the figure at the
top.
grid on;
It adds major grid lines to
the current axes.
______________
MATLAB program for impulse waveform generation
Program Code
n=-5:5;y=[zeros(1,5) 1 zeros(1,5)];
stem (n,y);
xlabel ('Time');
ylabel ('Amplitude');
title ('Impulse Waveform');
grid on;
Output
Explanation of Program Code
clc;
It clears all input and
output from the Command Window display giving clean screen. It removes items
from workspace, freeing up system memory. After using clc, the scroll bar
cannot be used to see the history of functions, but still the up arrow can be
used to recall statements from the command history.
clear all;
It removes all variables from
the workspace. This frees up system memory.
close all;
It deletes all figures whose
handles are not hidden.
n=-5:5;
This command creates vector
n.
Vector n is given by
n= [-5 -4
-3 -2 -1
0 1 2 3 4 5]
Here vector n is used as x
axis
y=[zeros(1,5) 1 zeros(1,5)];
This command creates impulse
waveform.
stem (n,y);
This command plots n versus
the columns of y as stems. . n and y must be vectors or matrices of the same
size. Additionally, n can be a row or a column vector and y a matrix with
length(n) rows.
This command makes impulse
waveform appear on the screen.
xlabel ('Time');
It labels the x-axis as 'Time'.
Each axes graphics object can have one label for
the x-, y-, and z-axis. The label appears beneath its respective axis in a
two-dimensional plot.
ylabel ('Amplitude');
It labels the y-axis as '
Amplitude. '
title ('Impulse Waveform');
It outputs the phrase 'Impulse Waveform' above the figure at the
top.
grid on;
It adds major grid lines to
the current axes.
________________
MATLAB program for sawtooth waveform generation
Program Code
t=0:0.01:4;y=sawtooth(2*pi*t+pi);
plot (t,y);
axis ([0 4 -5 5]);
xlabel ('Time');
ylabel ('Amplitude');
title ('Sawtooth Waveform');
grid on;
Output
Explanation of Program Code
clc;
It clears all input and
output from the Command Window display giving clean screen. It removes items
from workspace, freeing up system memory. After using clc, the scroll bar
cannot be used to see the history of functions, but still the up arrow can be
used to recall statements from the command history.
clear all;
It removes all variables from
the workspace. This frees up system memory.
close all;
It deletes all figures whose
handles are not hidden.
t=0:0.01:4;
Here vector t is created as
time axis.
Vector t has 401 elements.
The starting element is 0 and the final element is 4. There is an increment of
0.01 between consecutive elements of vector t.
y=sawtooth(2*pi*t+pi);
It creates the sawtooth
waveform.
plot (t,y);
It plots all the lines
defined by t versus y pairs. That is, it makes the sawtooth waveform appear on
the screen.
axis ([0 4 -5 5]);
It sets the limits for the x-
and y-axis of the current axes.
Here according to the above
command x-axis begins at 0 and ends at 4. Here y-axis begins at -5 and ends at
5.
xlabel ('Time');
It labels the x-axis as 'Time'.
Each axes graphics object can have one label for
the x-, y-, and z-axis. The label appears beneath its respective axis in a
two-dimensional plot.
ylabel ('Amplitude');
It labels the y-axis as '
Amplitude. '
title ('Sawtooth Waveform');
It outputs the phrase 'Sawtooth Waveform' above the figure at
the top.
grid on;
It adds major grid lines to
the current axes.
_________________
Subscribe to:
Posts (Atom)
For sale
Indian currency Ten-rupee note in good condition. Issued by the Reserve Bank of India between 22 December 1992 and 21 December 1997. Serial number 52T332603 . Those interested to buy, please contact: Anju K, Email: tc9749@gmail.com . Address: 'Sreyas', House no.7/296, Pulliodi, Kathiroor village, Ponniam east PO, via Ponniam west, Thalassery, Kannur, Kerala - 670641, India.