Create an ellipse at 45 degree angle

19 vues (au cours des 30 derniers jours)
Michelle Patrick-Krueger
Michelle Patrick-Krueger le 22 Nov 2022
Commenté : Star Strider le 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.

Réponse acceptée

Star Strider
Star Strider le 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 commentaires
Torsten
Torsten le 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 le 22 Nov 2022
@Michelle Patrick-Krueger — As always, my pleasure!!
@Torsten — Noted. Thank you!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by