how to get the position of a line in from a 2D matrix data.

2 visualizzazioni (ultimi 30 giorni)
can anyone help me to get the data from a 2D matrix along any crosssection (after drawing a line).
I need to extract such datapoints from a 2D matrix which will direclty underly the straight line as shown in figure.
Actually I need the intersection position or location of a line in 2D grid.
data size: x = (164,164); y = (164,164); data = (164,164)
Thanks in Advance.

Risposte (2)

KSSV
KSSV il 30 Lug 2021
If you have grid data X, Y,Z and you want to get the values at the points (x,y), you can use interp2.
zi = interp2(X,Y,Z,x,y) ;
To calculate the intersection points consider using InterX from file exchange.: https://in.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections

Walter Roberson
Walter Roberson il 30 Lug 2021
Note that you pass in endpoints of line segments, and it automatically decides the exact list of points to sample along.
If you want more control over exactly where it is sampled, then instead of using improfile(), use interp2(), supplying vectors for the x and y query points -- and be careful about x and y versus row and columns (x == columns, y == rows). When your x and y query vectors are the same size and same orientation, then the values will be interpolated at those points only (if they have different orientations then the query would be over a grid if I recall correctly.)

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by