% iidfield1.m generates and graphs a matrix of iid variables gridsize = [40 40]; % dimensions of data matrix [x,y] = easygrid([0 10 0 10], gridsize); % [xmin xmax ymin ymax] Z = rand(gridsize); % matrix with Uniform(0,1) entries subplot(3,2,1) % plot 1 in a 3 by 2 array of plots mesh(x,y,Z) % create a mesh surface plot of Z view(-10,50) % horiz. rotation, vert. elevation xlabel('Horizontal'); ylabel('Vertical'); zlabel('Intensity'); title('Surface plot'); subplot(3,2,2) mesh(x,y,Z) view(80,50) % view rotated by 90 degrees xlabel('Horizontal'); ylabel('Vertical'); zlabel('Intensity'); title('Surface plot'); subplot(3,2,3) contour(x,y,Z,20) % contour plot w/ 20 contour lines title('Contour plot') subplot(3,2,4) pcolor(x,y,Z) % color or grayscale plot shading flat % no lines between matrix entries title('Intensity plot') subplot(3,2,5) hist(reshape(Z,1,prod(gridsize))) % histogram entries of Z title('Histogram of field values')