How to perform interpolation on a 2D array in MATLAB -
how can make function of 2 variables , given 2d array, return interpolated value?
i have n x m
array a
. need interpolate , somehow obtain function of surface pick values on not-integer arguments. (i need use interpolation function of 2 variables)
for example:
a[n,m] //my array // here method i'm looking for. returns function interpolateda interpolateda(3.14,344.1) //that function returns interpolated value
for data on regular grid, use interp2. if data scattered, use griddata. can create anonymous function simplified wrapper around calls.
m = 10; n = 5; = rand(m,n); interpolateda = @(y,x) interp2(1:n,1:m,a,x,y); %interpolateda = @(y,x) griddata(1:n,1:m,a,x,y); % alternative interpolateda(3.3,8.2) ans = 0.53955
Comments
Post a Comment