Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/griddata_fast.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit 4ec37fd8 on 2023-10-03 22:00:32 UTC
a33039f58e Alis*0001 function zi = griddata_fast(delau,z,method)
                0002 %GRIDDATA_FAST Data gridding and surface fitting.
                0003 %   ZI = GRIDDATA_FAST(DEL,Z)
                0004 %
                0005 %   See also GRIDDATA_PREPROCESS
                0006 
                0007 %   Based on
                0008 %   Clay M. Thompson 8-21-95
                0009 %   Copyright 1984-2001 The MathWorks, Inc. 
                0010 
4ec37fd829 Jean*0011 narginchk(2,3)
a33039f58e Alis*0012 
                0013 if nargin<3, method = 'linear'; end
                0014 if ~isstr(method), 
                0015   error('METHOD must be one of ''linear'',''cubic'',''nearest'', or ''v4''.');
                0016 end
                0017 
                0018 
                0019 % Sort x and y so duplicate points can be averaged before passing to delaunay
                0020 
                0021 switch lower(method),
                0022   case 'linear'
                0023     zi = linear(delau,z);
                0024 % case 'cubic'
                0025 %   zi = cubic(x,y,z,xi,yi);
                0026 % case 'nearest'
                0027 %   zi = nearest(x,y,z,xi,yi);
                0028 % case {'invdist','v4'}
                0029 %   zi = gdatav4(x,y,z,xi,yi);
                0030   otherwise
                0031     error('Unknown method.');
                0032 end
                0033   
                0034 if nargout<=1, xi = zi; end
                0035 
                0036 
                0037 %------------------------------------------------------------
                0038 function zi = linear(del,z)
                0039 %LINEAR Triangle-based linear interpolation
                0040 
                0041 %   Reference: David F. Watson, "Contouring: A guide
                0042 %   to the analysis and display of spacial data", Pergamon, 1994.
                0043 
                0044 z = z(:).'; % Treat z as a row so that code below involving
                0045             % z(tri) works even when tri is 1-by-3.
                0046 zi = sum(z(del.tri) .* del.w,2);
                0047 
                0048 zi = reshape(zi,del.siz);
                0049 
                0050 if ~isempty(del.out), zi(del.out) = NaN; end
                0051 
                0052 %------------------------------------------------------------