ON HOLD % meshgrid now required to generate 3D graphics rendering mesh data X = [. 1: 10;. 3: 12 is;. 5: 14]; % primary colors red, green and blue Map = zeros (256,3); Map (:, 2) = (0: 255) / 255; the colormap (Map); % the imagesc (a) the value of the element size of the matrix a into a different color by the imagesc (X); the colorbar; HOLD OFF
Mesh () is used to draw a three-dimensional curved surface is not particularly fine grid map, the lines indicate the same level with the same color. Surf () for drawing a three-dimensional surface mesh is relatively smooth FIG complement surface between the lines is filled with color.
hold on x=-3.5:0.2:3.5; y=-3.5:0.5:3.5; [x,y]=meshgrid(x,y); z=x.*exp(-x.^2-y.^2); subplot(1,2,1);mesh(x,y,z); subplot(1,2,2);surf(x,y,z); hold off
Contour () contour map matrix
contour(u,v,z,n)是画等值线
其第四个参数是控制等值线的值的
如果n是一个标量,那么解释为等值线的条数例如
contour(u,v,z,20)那么它会根据数据的范围画出20条等值线
如果n是一个向量,那么解释为需要等值线的值,例如
contour(u,v,z,[1 2 3 4])会画出z=1,2,3,4四个值的等值线
如果我们要只要画指定的某个值的等值线,我们就用两个相同的数组成向量
contour(u,v,z,[1 1]);画值为1的等值线
contour(u,v,z,[0 0]);画值为0的等值线
hold on x=-3.5:0.2:3.5; y=-3.5:0.5:3.5; [x,y]=meshgrid(x,y); z=x.*exp(-x.^2-y.^2); subplot(1,3,1);contour(z,[-.45:.05:.45]);axis square; subplot(1,3,2);[c,h]=contour(z); %把等高线的数值标上去 clabel(c,h);axis square; %contourf把等高线图填充颜色 subplot(1,3,3);contourf(z);axis square; hold off