function z=nmd2plot(x,y,w,sigma,mu,g)

% NMD2PLOT    Bi-variate normal mixture density plot.
%
%             Example: load nmd2
%                      [X,Y]=meshgrid(-4:0.2:4);
%                      nmd2plot(X,Y,wk,sigmak,muk); 
%
%             NMD2PLOT(X,Y,W,SIGMA,MU,G)
%
%             Christian C. Beardah 1996

if nargin==5,
  g=1;
end;

z=zeros(size(x));

for i=1:length(w),
  z=z+w(i)*npdf2(x,y,mu(:,i),sigma(:,(2*i-1):2*i));
end;

xa=x(1,:);
ya=y(:,1);

zmax=max(max(z));
inc=zmax/10;

if g~=0,
  contour(xa,ya,z,[inc:inc:(zmax-inc)],'c');
end;