/[MITgcm]/MITgcm/utils/matlab/griddata_preprocess.m
ViewVC logotype

Diff of /MITgcm/utils/matlab/griddata_preprocess.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3 by jmc, Fri May 29 14:03:30 2009 UTC revision 1.4 by mlosch, Thu Jul 11 12:41:06 2013 UTC
# Line 54  siz = size(xi); Line 54  siz = size(xi);
54  xi = xi(:); yi = yi(:); % Treat these as columns  xi = xi(:); yi = yi(:); % Treat these as columns
55  x = x(:); y = y(:); % Treat these as columns  x = x(:); y = y(:); % Treat these as columns
56    
57  % Triangularize the data  % older version of matlab do not have DelaunayTri, later versions do not
58  tri = delaunayn([x y]);  % have tsearch
59  if isempty(tri),  msg=which('DelaunayTri');
60    warning('Data cannot be triangulated.');  if length(msg) > 0 % version is 2012 or newer
61    return    % Triangularize the data
62  end    tri=DelaunayTri(x,y);
63      if isempty(tri),
64        warning('Data cannot be triangulated.');
65        return
66      end
67      
68      % Find the nearest triangle (t)
69      [t, bcs] = pointLocation(tri, xi, yi);
70      
71    else % use delaunay and tsearch (and hope it is available)
72    
73  % Find the nearest triangle (t)    % Triangularize the data
74  t = tsearch(x,y,tri,xi,yi);    tri = delaunayn([x y]);
75      if isempty(tri),
76        warning('Data cannot be triangulated.');
77        return
78      end
79      
80      % Find the nearest triangle (t)
81      t = tsearch(x,y,tri,xi,yi);
82    
83    end % end of selecting version
84    
85  % Only keep the relevant triangles.  % Only keep the relevant triangles.
86  out = find(isnan(t));  out = find(isnan(t));

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22