Mary
Mary

Reputation: 788

Bicubic interpolation beyond grid values in Matlab

Is it possible to achieve bi-cubic interpolation beyond grid values? For example:

L = [5,10,20,25,40];
W= 1:3;
S= [50 99 787
    779 795 850
    803 779 388
    886 753 486
    849 780 598];
size1 = griddata(W,L,S,2,40,'cubic')
sizeBeyond = griddata(W,L,S,2,41,'cubic')
sizeV4 = griddata(W,L,S,2,41,'v4')

returns:

size1 = 780

sizeBeyond = NaN

sizeV4 = 721.57

Upvotes: 1

Views: 272

Answers (1)

Siva Srinivas Kolukula
Siva Srinivas Kolukula

Reputation: 1251

What I was suggesting is, you can input the values which are extrapolated. Check the below code. But note that, as suggested by flawr, the extrapolation behave really bad.

l = [5,10,20,25,40];
w = 1:3;

li = [l 41] ;

S = [50 99 787
    779 795 850
    803 779 388
    886 753 486
    849 780 598];
[W,L] = meshgrid(w,l) ;
[Wi,Li] = meshgrid(w,li) ;
Si = interp2(W,L,S,Wi,Li,'spline') ;

size1 = griddata(W,L,S,2,40,'cubic')
sizeBeyond = griddata(Wi,Li,Si,2,41,'cubic')
sizeV4 = griddata(W,L,S,2,41,'v4')

Note: Don't use inbuilt commands like length,size etc as variables in the code, even for demonstration, it is trouble some.

Though, this is not answer, I have to post it here as for discussion.

Upvotes: 0

Related Questions