% % Problem Epage 201 % Example 5.18 Epage 162/Example on Epage 165 % % isosurface/isocaps % % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clear all; close all; clc; %-- % plot the isosurfaces of the trivariate Gaussian %-- % create a grid for the domain: [x,y,z] = meshgrid(-3:.1:3,-3:.1:3,-3:.1:3); [n,d] = size(x(:)); % fill our volume with values of the trivariate normal density: a = (2*pi)^(3/2); arg = (x.^2+y.^2+z.^2); prob = exp((-0.5)*arg)/a; % <- this is the data we want to plot an isosurface for: % plot some alpha-level contours: mymx=max(prob(:)); % Use isosurfac: % for i = [0.4,0.6] % <- the alpha to use figure; val = i*mymx; hpatch = patch(isosurface(prob,val),'FaceColor','blue'); isonormals(prob,hpatch); end % Use isocaps: % for i = [0.4,0.6] % <- the alpha to use figure; val = i*mymx; hpatch = patch(isosurface(prob,val),'FaceColor','blue'); isonormals(prob,hpatch); patch(isocaps(prob,val),'FaceColor','interp','EdgeColor','none'); end