Extract value from a 3D array with interpolation
이전 댓글 표시
I have a 3D array with row (row_ID), column (col_ID) and Z (z_ID) identifiers.
Essentially what I need is:
- For a particular (row_ID, col_ID, z_ID), return the data value stored at that location.
- If the (row_ID, col_ID) are not integers, then perform an interpolated value. z_ID will always be an integer.
Thank you
답변 (1개)
KSSV
2017년 2월 7일
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
BenL
2017년 2월 7일
KSSV
2017년 2월 7일
Yes row and col is your desired row_ID, col_ID and z value is what you find i.e iwant.
BenL
2017년 2월 7일
BenL
2017년 2월 7일
Walter Roberson
2017년 2월 7일
KSSV
2017년 2월 7일
interp2 is not linear ...Read documentation...As suggested by Walter have a look into griddedInterpolant.
Walter Roberson
2017년 2월 7일
카테고리
도움말 센터 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!