Regarding distance determination in an ellipse from a matlab ( 2013) plot

hi everyone i am a new user in matlab. And i have started to use matlab 2013 . And by running a program i got an elliptic plot . As i have generated different size of ellipses, now i want to determine the semimajor axes and semiminor axes of that ellipses from that plots........So can anyone help me by giving any idea how can i get that from different graphs............

2 comentarios

I think we need to know how you generated the ellipses. I mean, why don't you already have that information since you are the one who generated the ellipses? Do you have a list of some (x,y) coordinates? Do you have an image? Exactly what form is this ellipse in ?
I have generated the plot(which is elliptic in nature) simply running an matlab code ..... thats why i dont have any co-ordinate for this x,y directly..........and this plot is generated from matlab......so its simply in its format......but as i am completely new so if you will give me some suggestion then it will be helpful for me.

Iniciar sesión para comentar.

Respuestas (2)

In the case you are not working with a large number of plot you can use the ginput command (you place the mouse in a point and Matlab return the coordinates of that point) http://www.mathworks.es/es/help/matlab/ref/ginput.html, once you have the coordinates you can determine the semimajor axes and semiminor axes using the euclidean distance formula
d=sqrt((x1-x2)^2+(y1-y2)^2);

4 comentarios

Thanks for your reply.......but where i will make that command , can you pls give me any example.........as i have a plot .........if you will give me an example then it will be good for me..........
Carlos
Carlos el 27 de Mzo. de 2014
Editada: Carlos el 27 de Mzo. de 2014
Lets say you plot
x = 0:0.01:3.14;
plot(sin(x));
and you write in your code
[x_coord y_coord] = ginput(1);
Then when you press the mouse arrow pointing to the point whose coordinates you want to find out, you will have the point's coordinates stored in x_coord y_coord, and then you could use the formula to find the distance
Thank you for helping me.........And actually i have done in this way last night.....but i think it is very crude way to determine the length.........so can you give me any other procedure to get this in a proper length...........then it will be effective for me.......
Sorry, this is the only way I can think of now, perhaps if you give us some more insight about how you actually generate the ellipses with Matlab
And yes I agree the method proposed is not very elegant, but you have to bare in mind you want to get the values from an image...
Just to make things clear I have generated an ellipse, and I have calculated the semiminor axes in the way I have proposed. The result should have been 3 and I got 2.9914.
a=4;
b=3;
x0=0;
y0=0;
t=-pi:0.1:pi;
x=x0+a*cos(t);
y=y0+b*sin(t);
plot(x,y)
>> [x_coord y_coord] = ginput(1);
>> d=sqrt(x_coord^2+y_coord^2)
d =
2.9914

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 28 de Mzo. de 2014
You say: "I have generated the plot(which is elliptic in nature) simply running an matlab code" Well, what code did you use ? Did you use the code to generate an ellipse on the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_an_ellipse.3F? My point is, if you used MATLAB to generate an ellipse and plot it, you ALREADY have and know the axes lengths. Show the line of code you used to generate the (x,y) and plot them.

2 comentarios

100% agree if he has used a Matlab code to generate the plots hence he must have the points.
Perhaps he is plotting experimental data which is generating elliptic plots
If so, it would be helpful to attach the data file and the code used to read it in.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Exploration en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Mzo. de 2014

Comentada:

el 28 de Mzo. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by