How to plot an Ellipse?

3 次查看(过去 30 天)
Artur Avazov
Artur Avazov 2016-2-25
Good day, dear users,
I started to study MATLAB language and now I would like to plot an ellipse from the data array.
I have this data for plotting several ellipses:
Here will be [c1 c2 a1 a2] correspondingly. Every line is for one ellipse.
EllipsesData =
90 300 82 70
92 65 12 12
80 150 12 12
290 38 12 12
458 127 12 12
246 251 20 16
175 180 47 37
337 169 75 50
430 257 41 32
394 353 25 30
524 280 14 22
244 355 24 17
290 355 24 17
I have created an array and saved it in EllipsesData.dat. Further, I will call the values from this file. The equation defining an ellipse is following:
(x - c1).^2 ./ a1^2 + (y - c2).^2 ./ a2^2 <= 1
The main code for plotting an ellipse I did is here:
load EllipsesData.dat;
x = input('Enter the x coordinate');
y = input('Enter the y coordinate');
c1 = EllipsesData(1,1);
c2 = EllipsesData(1,2);
a1 = EllipsesData(1,3);
a2 = EllipsesData(1,4);
ellipse1 = (x - c1).^2 ./ a1^2 + (y - c2).^2 ./ a2^2 <= 1;
plot(ellipse1)
axis([x-10 x+10 y-10 y+10]);
grid on;
xlabel('x');
ylabel('y');
title('Ellipse');
After I launch it I get the empty figure
Could you please help me with this thing? Thank you in advance for your clarifying!
Moreover, I would like to plot all the ellipses in one figure, so for this it seems to me that I will need to use switch-case(number), input('number for plotting 'number' ellipse), hold on function.

回答(1 个)

Muhammad Usman Saleem

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by