Create an ellipse at 45 degree angle

25 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2022-11-22
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 个评论
Torsten
Torsten 2022-11-22
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')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by