How to draw a rotated ellipse without any toolbox?

16 ビュー (過去 30 日間)
ManKit Tse
ManKit Tse 2012 年 8 月 28 日
コメント済み: Vivek Bhartiya 2020 年 3 月 30 日
I need to draw rotated ellipse on a Gaussian distribution plot by surf. I am using a student version MATLAB. Can i still draw a ellipse center at estimated value without any toolbox that required money to buy. I search on internet somebody write ellipse function and allow to download. Are they work well on surf plot.

採用された回答

Babak
Babak 2012 年 8 月 28 日
編集済み: Babak 2012 年 8 月 28 日
t = linspace(0,2*pi,1000);
theta0 = pi/6;
a=2;
b=1;
x = a*sin(t+theta0);
y = b*cos(t);
plot(x,y)
axis equal
  3 件のコメント
Image Analyst
Image Analyst 2012 年 9 月 2 日
Well yeah, because if a or b is really close to zero, the width is really close to zero and the ellipse is essentially almost a line. And a line has to lie along the raster lines on your monitor. The line can be on line 1 or on line 2. You can't have pixels going across the screen at line 1, line 1.01, line 1.02, etc. up to line 1.88 or whatever. It's got to be just on line 1 or on line 2, not on fractional lines. For further reading: http://en.wikipedia.org/wiki/Jaggies
Gabriel Hernandez
Gabriel Hernandez 2019 年 12 月 9 日
編集済み: Gabriel Hernandez 2019 年 12 月 9 日
This code did not work for me. The answer posted below is much more accurate.

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

その他の回答 (1 件)

Oleksii Sidorov
Oleksii Sidorov 2018 年 2 月 26 日
My version with general parametric equation of rotated ellipse, where 'theta' is angle of CCW rotation from X axis (center at (x0, y0))
t = linspace(0,2*pi,100);
theta = deg2rad(105);
a=2;
b=1;
x0 = 0.15;
y0 = 0.30;
x = x0 + a*cos(t)*cos(theta) - b*sin(t)*sin(theta);
y = y0 + b*sin(t)*cos(theta) + a*cos(t)*sin(theta);
figure;
plot(x,y);
axis equal;
  2 件のコメント
Gabriel Hernandez
Gabriel Hernandez 2019 年 12 月 9 日
Your code worked perfectly for me, much better than the one from the accepted answer. Thank you!
Vivek Bhartiya
Vivek Bhartiya 2020 年 3 月 30 日
Fantastic work. It was quite hard to find a functional code.

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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by