1  %'griddata_uvmat': function griddata_uvmat(vec2_X,vec2_Y,vec2_U,vec_X,vec_Y,'linear')


2  %adapt the input of the matlab function griddata to the appropriate version of Matlab


3  function ZI = griddata_uvmat(X,Y,Z,XI,YI,rho)


4  if ~exist('rho','var') isequal(rho,0)


5  txt=ver('MATLAB');


6  Release=txt.Release;


7  relnumb=str2num(Release(3:4));


8  if relnumb >= 20


9  ZI=griddata(double(X),double(Y),double(Z),double(XI),double(YI),'linear',{'QJ'});


10  elseif relnumb >=14


11  ZI=griddata(X,Y,Z,XI,YI,'linear',{'QJ'});


12  else


13  ZI=griddata(X,Y,Z,XI,YI,'linear');


14  end


15  else %smooth with thin plate spline


16  [ZI,Z_diff]=patch_uvmat(X,Y,Z,XI,YI,rho);


17  diff_norm=mean(Z_diff.*Z_diff)


18  ind_good=find(abs(Z_diff)<5*diff_norm);


19  nb_remove=numel(Z_diff)numel(ind_good)


20  if nb_remove>0


21  X=X(ind_good);


22  Y=Y(ind_good);


23  Z=Z(ind_good);


24  [ZI,Z_diff]=patch_uvmat(X,Y,Z,XI,YI,rho);


25  diff_norm_new=mean(Z_diff.*Z_diff)


26  end


27  end 
