mm4d.m
来自「一套从入门到精通的Matlab学习教材」· M 代码 · 共 66 行
M
66 行
% mm4decho onx=-7.5:.5:7.5; % create a data set - the famous sombreroy=x;[X Y]=meshgrid(x,y); % create plaid dataR=sqrt(X.^2+Y.^2)+eps;Z=sin(R)./R;figure(1)colormap(hot)surf(X,Y,Z,Z) % default color ordertitle('Default color')% press any key to continuepausesurf(X,Y,Z,-Z) % plot and reverse the default color ordertitle('Flip color upside-down')% press any key to continuepausesurf(X,Y,Z,X) % color varies along the X axistitle('Vary color along X-axis')% press any key to continuepausesurf(X,Y,Z,X+Y) % color varies along the XY diagonaltitle('Vary color along X-Y diagonal')% press any key to continuepausesurf(X,Y,Z,R) % color varies radially from the centertitle('Vary color radially in x-y plane')% press any key to continuepausesurf(X,Y,Z,abs(del2(Z))) % color varies with absolute value of Laplaciantitle('Vary color by Laplacian')% press any key to continuepause[dZdx,dZdy]=gradient(Z);surf(X,Y,Z,abs(dZdx)) % color varies with absolute slope in x-directiontitle('Vary color with absolute slope in X-direction')% press any key to continuepausesurf(X,Y,Z,abs(dZdy)) % color varies with absolute slope in y-directiontitle('Vary color with absolute slope in Y-direction')% press any key to continuepausedZ=sqrt(dZdx.^2 + dZdy.^2);surf(X,Y,Z,dZ) % color varies with magnitude of slopetitle('Vary color with magnitude of slope')echo off
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?