필터 지우기
필터 지우기

To crate a 2D lookup table with interpolation for matrix data and to crate a function of (x,y) (inputs) give the output from the matrix

조회 수: 49 (최근 30일)
I have data matrix, for an example:
A=[0,1,2,3,4,5; 2,3,5,6,6;3 3 5 0 9]; % A data matrix.
x=-100:5:100; % x-axis
y=-100:5:100; % y-axis
i want to for any (x,y) value (in the range -100 to 100) to obtain the matrix vaule, so two things need to do covert the index A(i,j) to A(x,y) and to inerpolated between breaking point, for an eaxmple A(1,2.5) .

답변 (1개)

KSSV
KSSV 2019년 8월 1일
Read about interp2.
n = 20 ;
Z = peaks(n) ;
[X,Y] = meshgrid(1:n,1:n) ;
[Xi,Yi] = meshgrid(1:0.1:n,1:0.1:n) ;
Zi = interp2(X,Y,Z,Xi,Yi) ;
  댓글 수: 2
Dror Malka
Dror Malka 2019년 8월 4일
Thanks, but i want to get the value of the matrix for each x and y axis, for an exampl if i have two points betwee 0-5, then y=ax+b so it is to define in 1D problem and then for each x to get the y. However in my case, i have 2D so not sure if to do it on both axis (x,y), and then to avarege them, the interp2 just give you a larger samples but not for each x and y locations.
John D'Errico
John D'Errico 2019년 8월 4일
That is EXACTLY what interp2 will do. It does not just sample the data. It interpolates the data array at any list of points. And this is exactly what you asked for.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by