MATLAB program for square wave generation

Program Code
t=0:0.01:4;
y=square(2*pi*t,50);
plot (t,y);
axis ([0 4 -2 2]);
xlabel ('Time');
ylabel ('Amplitude');
title ('Square 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=square(2*pi*t,50);
This command creates a square waveform.

plot (t,y);
It plots all the lines defined by t versus y pairs. That is, it makes the square waveform appear on the screen.

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 x axis(time 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 y axis as amplitude.

title ('Square Waveform');
It outputs the phrase 'Square Waveform' above the figure at the top.

grid on;
It adds major grid lines to the current axes.
_________________

2 comments:

  1. I am regular reader, how are you everybody? This piece of writing posted at this website is truly
    pleasant.

    ReplyDelete
    Replies
    1. Respected Sir,
      I am the author of this website. My name is Anju K. Thank you for spending your valuable time to read this website regularly and for writing good opinion about this piece of writing posted at this website. I am happy to know that you are reading this website regularly. Thank you for spending your valuable time to inquire about my well-being. I am safe. I felt happy when you asked "How are you everybody?". I am greatly obliged to you. May you, your family and all your friends be always happy, healthy and successful in life.

      Please tell me your full name. If you are unable to reveal your name, then please tell me at least your profession.

      Delete

Please write your opinion about this MATLAB program here, only in English.

For sale

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.