griddata_nearest_vector

PURPOSE ^

GRIDDATA_NEAREST_VECTOR - interpolates a function on a grid

SYNOPSIS ^

function [u]=griddata_nearest_vector(x_m,y_m,u_m,x,y)

DESCRIPTION ^

GRIDDATA_NEAREST_VECTOR - interpolates a function on a grid

   This function returns interpolated u_m function of x_m and y_m,
   on the grid defined by x and y.
   INPUT x_m,y_m,u_M, x,y where x_m,y_m, u_m, x,y are all one dimensional vectors,
   See griddata_nearest_matrix for the case where x_m,y_m and u_m are matrices 
   and x,y are vectores.
   See griddata_perso for a user defined version of griddata ( with fuzz coeff).

   Usage:
      [u]=griddata_nearest_vector(x_m,y_m,u_m,x,y)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [u]=griddata_nearest_vector(x_m,y_m,u_m,x,y)
0002 %GRIDDATA_NEAREST_VECTOR - interpolates a function on a grid
0003 %
0004 %   This function returns interpolated u_m function of x_m and y_m,
0005 %   on the grid defined by x and y.
0006 %   INPUT x_m,y_m,u_M, x,y where x_m,y_m, u_m, x,y are all one dimensional vectors,
0007 %   See griddata_nearest_matrix for the case where x_m,y_m and u_m are matrices
0008 %   and x,y are vectores.
0009 %   See griddata_perso for a user defined version of griddata ( with fuzz coeff).
0010 %
0011 %   Usage:
0012 %      [u]=griddata_nearest_vector(x_m,y_m,u_m,x,y)
0013 
0014 u=zeros(length(x),1);
0015 for n=1:length(x),
0016    if mod(n,length(x)/10)==0,
0017       disp(n/length(x)*100);
0018    end
0019    
0020    dist=sqrt((x(n)-x_m).^2+(y(n)-y_m).^2);
0021    pos=find(dist==min(dist));
0022    if isnan(u_m(pos)),
0023       pos
0024    end
0025    
0026    u(n)=u_m(pos);
0027    
0028 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003