From blanton@marine.unc.edu Tue Nov 28 09:52:19 1995
Return-Path: <blanton@marine.unc.edu>
Received: from cuda.marine.unc.edu by whsun1 .wh.whoi.edu 
        (4.1/1.34/indent-1.0) id AA23041; Tue, 28 Nov 95 09:52:18 EST 
Received: (from blanton@localhost) by cuda.marine.unc.edu (8.6.11/8.6.11) id JAA04790 for jmanning@whsun1.wh.whoi.edu; Tue, 28 Nov 1995 09:52:18 -0500
From: Brian Blanton <blanton@marine.unc.edu>
Message-Id: <199511281452.JAA04790@cuda.marine.unc.edu>
Subject: Re: gridding & blanking with Matlab?
To: jmanning@whsun1.wh.whoi.edu (James Manning) (James Manning)
Date: Tue, 28 Nov 95 9:52:18 EST
In-Reply-To: <199511271437.JAA21083@foi.wh.whoi.edu>; from "James Manning" at Nov 27, 95 9:37 am
Mailer: Elm [revision: 70.85]
Status: RO

Jim, Contouring on irregularly spaced data in not easy in MATLAB.  There is 
a function called 'contoura.m'.  I've included below. I haven't
used it, but the rumor is that it does a good job.  Give it a test
and let me know what you think.  There may be other options we can explore.

Brian

************** CUT HERE AND SAVE AS "contoura.m" **************************
function [c,h]=contoura(x,y,z,a,b),
% CONTOURA CONTOURA plot.
%       CONTOURA(Z) is a contour plot of matrix Z treating the values in Z
%       as heights above a plane.
%       CONTOURA(X,Y,Z), where X and Y are vectors and Z is a matrix, specifies
%       the X- and Y-axes used on the plot.
%       CONTOURA(X,Y,Z), where X, Y, and Z are vectors, interpolates
%       the data onto a rectangular grid.
%       CONTOURA(Z,N) and CONTOURA(X,Y,Z,N) draw N contour lines, 
%       overriding the default automatic value.
%       CONTOURA(Z,V) and CONTOURA(X,Y,Z,V) draw LENGTH(V) contour lines 
%       at the values specified in vector V.
%       CONTOURA(...,'linetype') draws with the color and linetype specified,
%       as in the PLOT command.
%
%       C = CONTOURA(...) returns contour matrix C as described in CONTOURC
%       and used by CLABEL.
%       [C,H] = CONTOURA(...) returns a column vector H of handles to LINE
%       objects, one handle per line. 
% 
%       NOTE: Do not rename this CONTOUR, it calls CONTOUR.
%       See also CLABEL, CONTOURC, CONTOUR3, GRADIENT, QUIVER, PRISM.

%       D. Thomas 11/17/94
%       Copyright (c) 1984-94 by The MathWorks, Inc.
A = 'xyzab';
C = ',,,, ';

args = [A(1:nargin);[C(1:nargin-1) ' ']];
args = [args(:)' ' '];

if (nargout == 1),
        argo = 'c=';
elseif (nargout == 2),
        argo = '[c,h]=';
else
        argo = '';
end 

if (nargin > 2)
        if (min(size(x)) == 1 & min(size(y)) == 1 & min(size(z)) == 1),
                
                if  ~(size(x(:),1) == size(y(:),1) & size(y(:),1) == size(z(:),1)),
                        error('Sizes of X, Y, and Z must be equal');
                end
                xmin=min(x(:));
                ymin=min(y(:));
                xmax=max(x(:));
                ymax=max(y(:));
                N = ceil(length(x(:))^(1/2));
                Xl = xmin:((xmax-xmin)/(N-1)):xmax;
                Yl = ymin:((ymax-ymin)/(N-1)):ymax;
                [Xi,Yi]=meshgrid(Xl,Yl);
                Z = griddata(x,y,z,Xi,Yi);
                if (length(args) > 7),
                        args = [',',args];
                end
                eval([argo,'contour(Xl,Yl,Z',args(7:length(args)),');']);
        else,
                eval([argo,'contour(' args ');']);
        end
else,
        eval([argo,'contour(' args ');']);
end


