Assigning variables based on corresponding grid cells traversed by a line on a 2D grid plot
1 view (last 30 days)
Show older comments
Hi,
Assuming I have a 3x3 grid as follows, where the blue line is connecting two points (the red crosses):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/244840/image.png)
How would I code for MATLAB to return each grid cell passed through by this line i.e. to return the variables A, B, E and F?
I was thinking of coding along the lines of "if the line passes through coordinates in the x value range of ... and y value range of ... then return A" and so on for each grid cell.
If anyone could suggest how to code this considering it passes through a line simply formed by plotting two sets of coordinates, it would be much appreciated.
0 Comments
Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!