how to get the position of a line in from a 2D matrix data.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (2)
KSSV
am 30 Jul. 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
0 Kommentare
Walter Roberson
am 30 Jul. 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.)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!