Plot ellipsoids with an azimuth angle
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi there,
I have found this code online to plot an ellipse. However, the data I have contains the azimuth of the ellipse. How would I amend this code to plot the angle e.g. 70 degrees? when i replace the 0.01 in the code below or just put theta = 70, it doesn't plot anything.
Apprecaite your help in advance!
Many thanks :)
xCenter = 12.5;
yCenter = 10;
xRadius = 2.5;
yRadius = 8;
theta = 0 : 0.01 : 2*pi;
%theta= 70
x = xRadius * cos(theta) + xCenter;
y = yRadius * sin(theta) + yCenter;
plot(x, y,'r-', 'LineWidth', 3);
axis square;
%xlim([0 20]);
%ylim([0 20]);
grid on;
댓글 수: 0
채택된 답변
KSSV
2019년 3월 1일
YOu may rotate the ellipse at desired angle using rotation matrix.
xCenter = 12.5;
yCenter = 10;
xRadius = 2.5;
yRadius = 8;
theta = 0 : 0.01 : 2*pi;
%theta= 70
x = xRadius * cos(theta) + xCenter;
y = yRadius * sin(theta) + yCenter;
plot(x, y,'r-', 'LineWidth', 3);
T = 70*pi/180 ;
R = [cos(T) -sin(T) ;
sin(T) cos(T) ] ;
P = [x ; y] ;
P1 = R*(P-mean(P,2))+mean(P,2) ;
x1 = P1(1,:) ;
y1 = P(2,:) ;
hold on
plot(x1,y1,'b')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!