Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to treat plotted points differently according to their y-coordinates?

1 visualización (últimos 30 días)
ishbish
ishbish el 19 de Feb. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I've plotted a set of (functionally) random data points, and grouped them into visible sections according to their y-coordinates. I used a 'for-loop' with a line function, like this:
plot(x_rot,y_rot,'k.')
% This is the original data set
% Reading in the Highest and lowest x and y values of my data (finding the smallest rectangle that fits around it):
x_rot_min = min(x_rot);
x_rot_max = max(x_rot);
y_rot_min = min(y_rot);
y_rot_max = max(y_rot);
divs = (y_rot_max - y_rot_min)/(10);
% divs = data 'height'/(number of desired sections)
% = the vertical size of each section I'm dividing my data into
% Marking Those Sections on Our Original Plot
for y_sect = y_rot_min:divs:y_rot_max
hold on
line([x_rot_min,x_rot_max],[y_sect,y_sect])
hold off
end
OK, so far so good - this draws the lines shown in the attached plot. I now want, discretely, to find the mean x-coordinates of the data in each section, and have all of those mean x-coordinates listed out. Sadly, I have no idea where to even begin with this. The difficulty is that I need to avoid entering every section in manually, and would instead need to do each in turn for/while/if-style [alternatives welcome!], and then recompile their data into a single column or row array. Any help would be hugely appreciated - thanks!

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by