How to find the center point in this plot?

13 Ansichten (letzte 30 Tage)
Sabarinathan Vadivelu
Sabarinathan Vadivelu am 12 Feb. 2013
Kommentiert: Cameron Burgoni am 9 Apr. 2018
This is my plot. How to find the center point available in this plot?
  4 Kommentare
Sabarinathan Vadivelu
Sabarinathan Vadivelu am 13 Feb. 2013
Bearbeitet: Sabarinathan Vadivelu am 13 Feb. 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.
Sabarinathan Vadivelu
Sabarinathan Vadivelu am 13 Feb. 2013
I need a point that is nearer to the center of the square.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Feb. 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);

Weitere Antworten (1)

Thorsten
Thorsten am 12 Feb. 2013
x = rand(1,100);
y = rand(1,100);
plot(x, y, 'r*')
hold on
plot(mean(x), mean(y), 'k*', 'MarkerSize', 20)
  2 Kommentare
Sabarinathan Vadivelu
Sabarinathan Vadivelu am 13 Feb. 2013
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 am 9 Apr. 2018
Did you ever figure this out?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by