This is my plot. How to find the center point available in this plot?

4 commentaires

Walter Roberson
Walter Roberson le 12 Fév 2013
Do you want the center of mass, or do you want the mid-point of the x and y values ?
the cyclist
the cyclist le 12 Fév 2013
Do you have
  • Only the image?
  • The figure window actively open in MATLAB?
  • The data in the workspace from which the figure was created?
Sabarinathan Vadivelu
Sabarinathan Vadivelu le 13 Fév 2013
Modifié(e) : Sabarinathan Vadivelu le 13 Fév 2013
I want to extract the point (x,y) that is available near the center of the square. Also, I have all (x,y) coordinates of the points available in this plot.
I need a point that is nearer to the center of the square.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 13 Fév 2013
minx = min(x);
maxx = max(x);
centx = (minx + maxx) / 2;
miny = min(y);
maxy = max(y);
centy = (miny + maxy) / 2;
dist2 = (x - centx).^2 + (y - centy).^2;
[mindist2, idx] = min(dist2);
bestx = x(idx);
besty = y(idx);

Plus de réponses (1)

Thorsten
Thorsten le 12 Fév 2013
x = rand(1,100);
y = rand(1,100);
plot(x, y, 'r*')
hold on
plot(mean(x), mean(y), 'k*', 'MarkerSize', 20)

2 commentaires

I need a point that is nearer to the center of the point in the square. Not to plot an another point in the center.
Cameron Burgoni
Cameron Burgoni le 9 Avr 2018
Did you ever figure this out?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by