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

% NMD3PLOT    Tri-variate normal mixture density plot.
%
%             Example: load nmd3
%                      [X,Y,Z]=meshgrid(-4:0.2:4,-4:0.2:4,-4:0.2:4);
%                      F=nmd3plot(X,Y,Z,wa,sigmaa,mua); 
%
%             NMD3PLOT(X,Y,Z,W,SIGMA,MU,G)
%
%             Christian C. Beardah 1998

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

[r,c]=size(x);
f=zeros(size(x));

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

if g~=0,
  slice(x,y,z,f,mu(1,:),mu(2,:),mu(3,:),c);
end;