File Exchange

## ellipse.m

version 1.0 (2.26 KB) by

Adds ellipses to the current plot

4.63462
52 Ratings

Updated

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Adds ellipses to the current plot

behnam tayebi

swati bhugra

emilios

### emilios (view profile)

can someone please explain difference between ra, rb and ang in it?

Jerome De Lima

### Jerome De Lima (view profile)

RAJASEKHARREDDY POREDDY

### RAJASEKHARREDDY POREDDY (view profile)

Hi David Long, is there any possibility to get a point on the ellipse that we get from your program

light liu

### light liu (view profile)

very useful,thanks

Jenny

### Jenny (view profile)

Hi David, Thank you - I assumed as much but thought I ought to check! Thanks.

David Long

### David Long (view profile)

There is a typo in the comments section. ra is the semimajor axis, rb is the semimionr axis (ra>=rb), and ang is the angle of the semimajor axis.

Jenny

### Jenny (view profile)

Could anyone clarify for me the difference between ra and rb please? The function states that "% ELLIPSE(ra,rb,ang,x0,y0) adds an ellipse with semimajor axis of ra,
% a semimajor axis of radius rb, a semimajor axis of ang, centered at
% the point x0,y0."
I assume that one or the other should be semiminor axis?

Pragya Sharma

David Long

### David Long (view profile)

Using the pointer output ellipse as suggested in the previous comment, you can change the C argument to the standard patch command to use a vector (RGB) color. patch has some other interesting options you can use, too.

jaribeiro

### jaribeiro (view profile)

If instead of filling the ellipse with a specific color, would it be possible to fill it according to a vector?
How could that be done?

ramin bba

### ramin bba (view profile)

thanks. With a minor change it worked. the outputs (x, y) are cells so using patch gave me an error. I put your code in a for loop to get around the problem:

h=ellipse(ra,rb,ang,x0,y0,C,Nb);
x=get(h,'Xdata');
y=get(h,'Ydata');
for i=1:length(x)
hold on;
patch(x{i},y{i},'y');
hold off;
end

David Long

### David Long (view profile)

To efficiently produce a "filled" ellipse using this code, use the returned handle:
h=ellipse(ra,rb,ang,x0,y0,C,Nb);
x=get(h,'Xdata');
y=get(h,'Ydata');
hold on;
patch(x,y,'y');
hold off;

ramin bba

### ramin bba (view profile)

awesome code, helped me out a lot.

Do you have an efficient way in mind for "filling in" the ellipses? using patch maybe?

Chris

Frank

quite useful

David Long

Abhik

Jay Patel

Frederik

Kuider

### Kuider (view profile)

excellent! helped me a lot thank you

Yuri K

### Yuri K (view profile)

Congratulations for getting PoW! Great tool!

Laurent Ballaz

Nick Sinclair

Nitin

Zhang

### Zhang (view profile)

very good, very appreciate

Mohammed El-Said

### Mohammed El-Said (view profile)

Works Great,
Thanks for sharing...

Ben Bauer

piao lin

Antonio

### Antonio (view profile)

excellent work, useful and well documented¡¡¡

Chen Xing

### Chen Xing (view profile)

Many thanks!! Quick and simple

Bharat Pathak

Thank you very much.

Tory C

Great! Thank you! Is there a quick way to make the line thickness bigger?? Cant find the obvious fix in the code.

H J

A K

so cool!

thanks a lot

julio gomez

Fabiano Giuliani

A perfect function to draw an ellipse. Thank you!

Natt T

Thanks

MARGOT Gerritsen

Works like a treat

Y Liu

Andrzej Z

Reza Zahiri

nice and clean piece of code, thanks for sharing

kim jeongdae

thanks

peppo franco

jung sung yun

Yassir Al-Jahdir

Thank you very much!!

Kazimieras Bagdonas

thanx, yours function saved my day=)

Sanith Wijesinghe

Great

Stephen Westland

Saved my bacon today. Perfect.

Omar Muhanna

thank you very much for this file. because I was looking for such a function in MatLab that can draw for me an ellipse.but if you can send me the simpleat function for drawing such a simple ellipse I will be very greatful.

thank you...

Richard Weaver

Excellent- just what I needed - allows full user specification of the ellipse parameters.

peter YOU

Excelent

P Sirisalee

Many Thanks.

Paul Larsen

Works great! Thanks a million.

Yuval Tassa

Watch out for the missing semicolon in line 131. Otherwise, a great little util.

Gregory B

Thanks a lot!

Tom Thorvaldsen

Mark Wilde

i like a lot. makes me happier than the other 2 guys could ever be!

ke wang

It helps me a lot! Thank you very much

L. O'Neill

This function is easy to use, logical, and does exactly what it says it will. I am very happy with it.

MATLAB 5.2 (R10)