How to plot a Circle in Matlab
-
Upload
jorge-jasso -
Category
Software
-
view
168 -
download
8
description
Transcript of How to plot a Circle in Matlab
How to draw a Circle in Matlab
This also works in GNU-Octave,
FreeMat, Scilab and Scicoslab
We’re going to use paremetric equations to
describe a circumference in 5 easy steps.
1st. Step: define the values of the angles to
be considered.
angle = linespace(0, 2*pi, 360);
this defines 360 values from 0 to 2π radians.
2nd. Step: calculate the horizontal values of
your points:
x = cos(angle);
3rd. Step: calculate the vertical values of
your points:
y = sin(angle);
4th. Step: plot your 360 pairs of x and y
values:
plot(x, y)
5th. Step: force your x distance to equal
your y-distance in the plot:
axis('equal')
So this short code:
angle = linspace(0, 2*pi, 360);
x = cos(angle);
y = sin(angle);
plot(x, y)
axis('equal')
Produces this plot:
For more examples and details, visit:
matrixlab-examples.com/matlab-plot.html