Documentation of pncontm2


Global Index (short | long) | Local contents | Local Index (short | long)


Function Synopsis

[hh, cc] = pncontm(ya, xa, x, clev, lab, s);

Help text

     pncont(ya, xa, x, clev, lab, s);

     This function will plot positive contours of x in solid
     lines, and negative contours of x in dashed lines.

     pncont(x) pncont's the matrix 'x'.
     pncont(ya, xa, x) uses xa and ya as the x and y axes resp.
     pncont(ya, xa, x, clev) uses levels outlined in 'clev', or if
                             clev is an integer, uses clev levels.
     pncont(ya, xa, x, clev, lab) lab = 0 => don't label contours (default)
                                  lab = 1 => label contours
     pncont(ya, xa, x, clev, s) uses the (three letter) string 
                                in 's' to label positive, zero, and
                                negative contours (e.g., s='rkb' 
                                produces red positive, black zero, and
                                blue negative contours). 


Listing of function pncontm2

function [hh, cc] = pncontm(ya, xa, x, clev, lab, s);
lw = 1;
if nargin == 5;
  if isstr(lab);
    s = lab; lab = 0;
  else
    s = ['rkb'];
  end
end
if nargin < 5; lab = 0; s = ['rkb']; end;
if nargin < 4; clev = 10; end;
if nargin == 1;
  x = xa;
  [m, n] = size(x);
  xa = 1:n;
  ya = 1:m;
end;

if length(s) == 1; s = [s s s]; end;

[m,n] = size(x);

for i = 1:m;
  for j = 1:n;
    if x(i,j) <= 0;
      xp(i,j) = 0;
      xn(i,j) = x(i,j);
    else;
      xp(i,j) = x(i,j);
      xn(i,j) = 0;
    end;
  end;
end;

hh = [];
cc = [];
a = []; b = []; c = []; d = []; e = []; f = [];
hold on
if ~isempty(find(clev > 0));
  if (max(max(x)) > clev(find(clev == min(clev(find(clev > 0))))))
    [a, b] = contorm(ya, xa, xp, clev(find(clev)), ['-' s(1)]);
    if lab; clabelm(a, b, 'manual'); end;
    set(b,'linewidth',lw);
  end;
end

if ~isempty(find(clev < 0));
  if (min(min(x)) < clev(find(clev == max(clev(find(clev < 0))))));
    [c, d] = contorm(ya, xa, xn, clev(find(clev)), ['--' s(3)]);
    if lab; clabelm(c, d, 'manual'); end;
    set(d,'linewidth',lw);
  end;
end

if ~isempty(find(clev == 0));
  if (max(max(x)) > 0) & (min(min(x)) < 0 & ismember(0,clev) )
    [e, f] = contorm(ya, xa, x, [0 0], ['-' s(2)]);
    if lab; clabelm(e, f, 'manual'); end;
    set(f,'linewidth',2*lw);
  end;
end;

if nargout > 0;
  hh = [a c e];
  cc = [b; d; f];
end

%hold off
grid on;