Plotting Rotated Error Ellipses

10 ビュー (過去 30 日間)
Cory Smith
Cory Smith 2011 年 4 月 20 日
I have successfully been able to plot my error ellipse around a point but I haven't been able rotate the semi-major axis from the X-axis by a specified angle. The function I am using orients the ellipse to the x-axis but I need to represent the ellipse rotated by a specified angle. The function I am using is:
function plotEllipse(a,b,C)
% range to plot over
%------------------------------------
N = 50;
theta = 0:1/N:2*pi+1/N;
% Parametric equation of the ellipse
%
%----------------------------------------
state(1,:) = a*cos(theta);
state(2,:) = b*sin(theta);
% Coordinate transform (since your ellipse is axis aligned)
%----------------------------------------
X = state;
X(1,:) = X(1,:) + C(1);
X(2,:) = X(2,:) + C(2);
% Plot %----------------------------------------
plot(X(1,:),X(2,:));
hold on;
plot(C(1),C(2),'r*');
axis equal;
grid;
end
Any suggestions are welcomed.

採用された回答

Matt Fig
Matt Fig 2011 年 4 月 20 日
Please go back and format your code using the {}Code button.
EDIT Thanks for making your code readable!
Change this line:
plot(X(1,:),X(2,:));
to this:
L = plot(X(1,:),X(2,:));
and return L from your function.
Then from the command line, do:
L = plotEllipse(2,3,[5 9]);
rotate(L,[0 0 1],30) % Rotate the ellipse 30 degrees.
  1 件のコメント
Cory Smith
Cory Smith 2011 年 4 月 20 日
Worked perfectly thank-you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTwo y-axis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by