Plot ellipsoids with an azimuth angle

3 views (last 30 days)
P_L
P_L on 1 Mar 2019
Commented: P_L on 10 Mar 2019
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;

Accepted Answer

KSSV
KSSV on 1 Mar 2019
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')
  1 Comment
P_L
P_L on 10 Mar 2019
Hi KSSV, I ahve been trying to manipulate your answer into what I need but I am struggling.
I have for example data that has an error and an associated azimuth angle. I am wanting to plot an ellipse representing the area of error around each of my data points.
so I have for example my x,y data point with the error given by an amount 'Eminaxis' and 'Emaxaxis' and the azimuth to give the direction in which the ellipsoid points.
Is this something you could help further with?
Many Thanks

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!