% MidPeaks.m Peak functions for Midter Problem 3 and 4 % Show the 'Peaks' function; from the Matlab Help, % Mesh command. % The peaks function is: % z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... % - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... % - 1/3*exp(-(x+1).^2 - y.^2); % It is convenient to view over an x,y space of % -2 to +2 with an interval (dx = dy) of about % 0.05 to 0.2 % Peaks can also be viewed with plot3, surf, pcolor, etc. close all clear all clc format compact [X,Y] = meshgrid(-2:.125:2); Z = peaks(X,Y); meshc(X,Y,Z); axis([-2 2 -2 2 -10 5]) %% Multiply the 2-D array amplitudes by 2 %% Add random noise (randn) to the array randn('seed',igiven) % set random number seed %% Produce a contour plot