Assigning variables based on corresponding grid cells traversed by a line on a 2D grid plot

Hi,
Assuming I have a 3x3 grid as follows, where the blue line is connecting two points (the red crosses):
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.

Answers (0)

Asked:

BOB
on 24 Oct 2019

Edited:

BOB
on 24 Oct 2019

Community Treasure Hunt

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

Start Hunting!