フィルターのクリア

Plotting ellipses with parametric curves

83 ビュー (過去 30 日間)
Szabolcs Simon-Guth
Szabolcs Simon-Guth 2021 年 11 月 9 日
Hi all!
I need to plot the following ellipses on the same plot:
Ellips 1:
Ellipse 2:
I have substituted the formula for the second ellipse by u and v:
u =
v =
Ellipse 2:
I have used the following parametrisation:
For an ellipse with the general fomula
the parametrization: and
So, I have rearranged the equation of both ellipses to fit the general formula and then calculated a and b according the get the parametrization above. I was supposed to get the following plot:
Instead I have got this:
I have written the following code:
% First ellipse
t = linspace(0,2*pi,200);
a = sqrt(2);
b = sqrt(2/3);
x = a.*cos(t);
y = b.*sin(t);
plot(((1/2)*(x.^2)), ((3/2).*(y.^2)), '-k', 'LineWidth', 1.5)
axis equal
hold on
% Second ellipse
t = linspace(0,2*pi,200);
a = 2;
b = 1;
x = (-a/3).*(cos(t)+((-2*b/3).*sin(t)));
y = (((2*a/3).*cos(t))+((7*b/3).*sin(t)));
u = x-(2.*y);
v = (2.*x)+y;
plot(((1/4).*(u.^2)), ((v.^2)), '-k', 'LineWidth', 1.5)
axis equal
hold off
What is it that I'm doing wrong? I am very thankful for all the help in advance!

採用された回答

Chunru
Chunru 2021 年 11 月 9 日
% First ellipse
t = linspace(0,2*pi,200);
a = sqrt(2);
b = sqrt(2/3);
x = a.*cos(t);
y = b.*sin(t);
%plot(((1/2)*(x.^2)), ((3/2).*(y.^2)), '-k', 'LineWidth', 1.5)
plot(x, y, '-k', 'LineWidth', 1.5)
axis equal
hold on
% Second ellipse
t = linspace(0,2*pi,200);
a = 2;
b = 1;
u = a.*cos(t);
v = b.*sin(t);
xy= ([1 -2; 2 1])\[u; v]; % since [u; v] = [1 -2; 2 1][x; y]
xy = 2×200
0.4000 0.4124 0.4244 0.4360 0.4472 0.4579 0.4682 0.4780 0.4873 0.4961 0.5044 0.5123 0.5196 0.5264 0.5327 0.5384 0.5436 0.5483 0.5524 0.5560 0.5590 0.5615 0.5634 0.5647 0.5655 0.5657 0.5653 0.5644 0.5629 0.5609 -0.8000 -0.7933 -0.7858 -0.7775 -0.7684 -0.7586 -0.7480 -0.7367 -0.7246 -0.7118 -0.6984 -0.6842 -0.6693 -0.6537 -0.6376 -0.6207 -0.6033 -0.5852 -0.5666 -0.5474 -0.5277 -0.5074 -0.4866 -0.4654 -0.4436 -0.4215 -0.3989 -0.3759 -0.3525 -0.3288
x = xy(1, :);
y = xy(2, :);
%plot(((1/4).*(u.^2)), ((v.^2)), '-g', 'LineWidth', 1.5)
plot(x, y, '-g', 'LineWidth', 1.5)
axis equal
hold off
  1 件のコメント
Szabolcs Simon-Guth
Szabolcs Simon-Guth 2021 年 11 月 9 日
Thank you very much for the help! Apperantly, I have not done the variable transformation matrix. Thank you again! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by