필터 지우기
필터 지우기

Create an ellipse at 45 degree angle

조회 수: 25 (최근 30일)
Michelle Patrick-Krueger
Michelle Patrick-Krueger 2022년 11월 22일
댓글: Star Strider 2022년 11월 22일
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')
Star Strider
Star Strider 2022년 11월 22일
@Michelle Patrick-Krueger — As always, my pleasure!!
@Torsten — Noted. Thank you!
.

댓글을 달려면 로그인하십시오.

추가 답변 (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