02.03.2016 Views

MATLAB by rudra pratap

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.3 Lesson 3: Creating an< Print in g S !_ _ _ i m p le P l o ts ---' "--- __ _ _________________ 2_5<br />

2.3 Lesson 3: Creating and Printing Simple Plots<br />

Goa/: To learn how to make a simple 2-D plot in <strong>MATLAB</strong> and print it out.<br />

Time Estimates<br />

Lesson: 10 minutes<br />

Exercises: 40 minutes<br />

What you are going to learn<br />

• How to generate x- and y-coordinates of 100 equidistant points on a unit<br />

circle.<br />

• How to plot x vs. y and thus create the circle.<br />

• How to set the scale of the x-axis and the y-axis to be the same, so that the<br />

circle looks like a circle and not an ellipse.<br />

• How to label the axes with text strings.<br />

• How to title the graph with a text string.<br />

• How to ;et a hard copy of the graph.<br />

The MATI,AB commands used are<br />

plot<br />

axis<br />

xlabel<br />

ylabel<br />

title<br />

print<br />

creates a 2-D line plot,<br />

changes the aspect ratio of the x-axis and the y-axis,<br />

annotates the x-axis,<br />

annotates the y-axis,<br />

puts a title on the plot, and<br />

prints a hard copy of the plot.<br />

This lesson teaches you the most basic graphics commands. The exercises take<br />

you through various types of plots, overlay plots, and more involved graphics.<br />

Method: You are going to draw a circle of unit radius. To do this, first generate<br />

the data ( x- and y-coordinatcs of, say, 100 points on the circle), then plot the data,<br />

and finally print the graph. For generating data, use the parametric equation of a<br />

unit circle:<br />

X = cos B, y = sin B, 0 ::::; e ::::; 27r.<br />

In the sample session shown in Fig. 2.3, only the commands are listed. You<br />

should see the output on your screen.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!