Azzera filtri
Azzera filtri

Create an ellipse at 45 degree angle

25 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by