Extract value from a 3D array with interpolation

1 visualizzazione (ultimi 30 giorni)
BenL
BenL il 7 Feb 2017
Modificato: BenL il 9 Feb 2017
I have a 3D array with row (row_ID), column (col_ID) and Z (z_ID) identifiers.
Essentially what I need is:
  1. For a particular (row_ID, col_ID, z_ID), return the data value stored at that location.
  2. If the (row_ID, col_ID) are not integers, then perform an interpolated value. z_ID will always be an integer.
Thank you

Risposte (1)

KSSV
KSSV il 7 Feb 2017
load data.mat ;
A = gim_tec ;
[m,n,p] = size(A) ;
x = 1:n ;
y = 1:m ;
[X,Y] = meshgrid(x,y) ;
%%pick series if integer
row = 2 ;
col = 3 ;
iwant = zeros(1,p) ;
for i = 1:p
iwant(i) = A(row,col,i) ;
end
%%If fractions
row = 1.5 ;
col = 7.5 ;
iwant1 = zeros(1,p) ;
for i = 1:p
iwant1(i) = interp2(X,Y,A(:,:,i),row,col) ;
end
  8 Commenti
KSSV
KSSV il 7 Feb 2017
interp2 is not linear ...Read documentation...As suggested by Walter have a look into griddedInterpolant.
Walter Roberson
Walter Roberson il 7 Feb 2017
interp2 defaults to linear, but there are some options

Accedi per commentare.

Categorie

Scopri di più su Interpolation of 2-D Selections in 3-D Grids 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