Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Problem with Creating an Ellipse using Meshgrid

Subject: Problem with Creating an Ellipse using Meshgrid

From: Corey

Date: 6 Mar, 2013 16:18:08

Message: 1 of 2

I am interested in creating an ellipse from a meshgrid, which is centered on my image; however, it doesn't quite work. Can anyone assist me?

    [rows cols dims] = size(image)
    [x,y] = meshgrid(1:cols, 1:rows);
    f = sqrt((x-cols).^2/200 + (y-rows).^2/900) -1

I am not sure if my equation is correct?

Subject: Problem with Creating an Ellipse using Meshgrid

From: Luca

Date: 6 Mar, 2013 17:49:08

Message: 2 of 2

"Corey " <cdavis2000@hotmail.com> wrote in message
> I am not sure if my equation is correct?

No, It's not.
Depending on what you want to do it should be something like
 f = sqrt((x-x_c).^2/200 + (y-y_c).^2/900) -1
with x_c and y_c the center of your ellipse.
E.g.:
x_c = cols/2;
y_c = rows/2;


(and BTW, use ndgrid and not meshgrid. meshgrid is pure evil)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us