Borrar filtros
Borrar filtros

Problem in plot combination

3 visualizaciones (últimos 30 días)
Dimitris Arapidis
Dimitris Arapidis el 13 de Sept. de 2013
I have the following code:
dmin=0;
dmax=17.502503873106170;
zmin=8.735508217599295e+02;
zmax=2.249914400000071e+02;
axis (axis)
plot([dmin dmax],[zmin zmax],'r')
x1=dmin;
y1=zmin;
x2=dmax;
y2=zmax;
f = 100000;
r = 8.657*sqrt(dmax/f);
e = sqrt(1-(r/dmax)^2);
a = 1/2*sqrt((x2-x1)^2+(y2-y1)^2);
b = a*sqrt(1-e^2);
t = linspace(0,2*pi);
X = a*cos(t);
Y = b*sin(t);
w = atan2(y2-y1,x2-x1);
x = (x1+x2)/2 + X*cos(w) - Y*sin(w);
y = (y1+y2)/2 + X*sin(w) + Y*cos(w);
hold on, plot(x,y,'g-')
dmin, zmin are the x,y coordinates for point A, dmax, zmax are the x,y coordinates for point B. AB is both a straight line and the major axis of an ellipse. e is the eccentrity of the ellipse.
When i plot both line and ellipse the ellipse end up wrong. What should i do in order to plot the line as the ellipse major axis?

Respuestas (1)

Roger Stafford
Roger Stafford el 13 de Sept. de 2013
Editada: Roger Stafford el 13 de Sept. de 2013
Do you have the plot scaling the same for both the x and y axes? If not, that would distort the ellipse. Use
axis equal
  2 comentarios
Dimitris Arapidis
Dimitris Arapidis el 13 de Sept. de 2013
I already tried that, it didn't work
Roger Stafford
Roger Stafford el 13 de Sept. de 2013
I ran your program. Without the "axis equal" line the ellipse is naturally distorted because the scaling in x and y is so different in the plot and the two vertices at the ends of the major axis don't look like vertices.
With "axis equal" present the ellipse shows its true nature. Its eccentricity is so close to one (.99997859) that it is nearly a vertical straight line segment and the red line marking its major axis segment is nearly obscured. With equal scaling matlab is giving an accurate picture of the ellipse as it really is. Both the ellipse and the major axis are very nearly coincident vertical line segments.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by