plot half of an ellipse with a=40 and b=20 in matlab

To plot half of an ellipse in MATLAB with a = 40 and b = 20, first create a parameterized equation for the ellipse. Here is the equation:

main.m
x = 40*cos(t);
y = 20*sin(t);
30 chars
3 lines

Next, use the plot function to plot the ellipse from t = -pi/2 to t = pi/2:

main.m
t = linspace(-pi/2,pi/2,50);
x = 40*cos(t);
y = 20*sin(t);
plot(x,y);
70 chars
5 lines

This will plot half of the ellipse, with the major axis of length 80 along the x-axis and the minor axis of length 40 along the y-axis.

related categories

gistlibby LogSnag