Info
This question is closed. Reopen it to edit or answer.
How to treat plotted points differently according to their y-coordinates?
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!