Program Code
clc;clear all;
close all;
t=0:.5:4;
y=trapmf(t,[.5 1 2 2.5]);
plot (t,y);
axis ([0 4 -2 2]);
xlabel ('Time');
ylabel ('Amplitude');
title ('Trapezoidal Waveform');
grid on;
Output
Explanation of Program Code
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:.5:4;
It results in
t =[0 .5 1 1.5 2 2.5 3 3.5 4]
Here a vector t is created having starting element as 0.5 and last element as 4 and with an increment of 0.5 between the elements. Here this vector t is used as time axis(x axis) while plotting trapezoidal waveform.
y=trapmf(t,[0.5 1 2 2.5]);
It is used to create trapezoidal curve. Trapmf is trapezoidal-shaped built-in membership function of fuzzy logic toolbox.The trapezoidal curve is a function of a vector, t , and depends on 0.5, 1, 2 and 2.5as given by
f(t,0.5, 1, 2, 2.5)=
max{min{(t-0.5)/(1-0.5), 1, (2.5-t)/(2.5-2)} 0}
=max{min{(t-0.5)/0.5, 1, (2.5-t)/0.5} 0}
0.5 and 2.5 locate the "feet" of the trapezoid.
1 and 2 locate the "shoulders" of the trapezoid.
plot (t,y);
It plots all the lines defined by t versus y pairs.
axis ([0 4 -2 2]);
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 -2 and ends at 2.
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 ('Trapezoidal Waveform');
It outputs the phrase 'Trapezoidal Waveform' above the figure at the top.
grid on;
It adds major grid lines to
the current axes.
_______________________
This design is wicked! You most certainly know how tto keep a reader
ReplyDeleteamused. Between yoour witt and your videos, I was almost moved to start
my own blog (well, almost...HaHa!) Greazt job. I really loved
what you had to say, and more than that, howw youu presented it.
Too cool!
Respected Sir,
DeleteI am so happy to hear this from you. I would also like to know your name. Thank you for being kind enough to say such a good opinion about this blog of mine. Also, thank you for spending your valuable time to read this blog. May you, your family and all your friends have good health and happiness throughout your lives.
I'd like to thank you for the efforts you've put in penning this site.
ReplyDeleteI'm hoping to view thhe same high-grade blog posts by youu in the future aas
well. In truth, your creative writing abilities has encouraged
me to get my very own blog nnow ;)
Respected Sir,
DeleteThank you.
I am the author of this blog. My name is Anju K.
I thank you, for your good opinion about this blog and for spending your valuable time to visit this blog. Your opinion has greatly encouraged me.
Please tell me the name of your own blog. I would like to read a blog written by you.
I wish you, your family and all your friends, good health and happiness throughout their lives.