Filter löschen
Filter löschen

Create an ellipse at 45 degree angle

25 Ansichten (letzte 30 Tage)
Michelle Patrick-Krueger
Michelle Patrick-Krueger am 22 Nov. 2022
Kommentiert: Star Strider am 22 Nov. 2022
I am trying to create an ellipse of 1 standard deviation around the mean of a scatter plot. The scatter plot is a smear of points at a 45 degree angle.
I'm able to create an ellipse using:
rectangle('Position',cnr,'Curvature',[1,1]);
Where 'cnr' is [x y w h] of the ellpse, with the xy being the lower left corner of where the rectangle would start, but I haven't found anything on how to rotate the ellipse.
Thank you for any help you can give.

Akzeptierte Antwort

Star Strider
Star Strider am 22 Nov. 2022
I experiment with using the rotate funciotn on the rectangle and it wouldn’t move at all.
Try this instead —
v = linspace(0, 1);
rx = 0.5;
ry = 0.25;
x = rx*cos(2*pi*v + pi/4);
y = ry*sin(2*pi*v);
figure
plot(x, y)
grid
axis([-1 1 -1 1])
axis('equal')
Mak e appropriate changes to get the result you want.
.
  3 Kommentare
Torsten
Torsten am 22 Nov. 2022
I think a rotation by 45 degrees should be like this:
v = linspace(0, 1);
rx = 0.5;
ry = 0.25;
x = rx*cos(2*pi*v);
y = ry*sin(2*pi*v);
xx = x*cosd(45) - y*sind(45);
yy = x*sind(45) + y*cosd(45);
figure
plot(xx, yy)
grid
axis([-1 1 -1 1])
axis('equal')
Star Strider
Star Strider am 22 Nov. 2022
@Michelle Patrick-Krueger — As always, my pleasure!!
@Torsten — Noted. Thank you!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by