MATLAB中peaks函数的用法

MATLAB中peaks函数感觉比较有意思,是两个变量的样本函数。用法主要为

z=peaks;返回一个49*49的矩阵

z=peaks(n);返回一个n*n的矩阵

peaks(n);没有输出参数时,这个函数直接使用surf来绘制peaks,默认n为49

[x y z]=peaks(...);

[X,Y,Z] = peaks(...); returns two additional matrices, X and Y, for parametric plots, for example, surf(X,Y,Z,del2(Z)). If not given as input, the underlying matrices X and Y are

[X,Y] = meshgrid(V,V)

where V is a given vector, or V is a vector of length n with elements equally spaced from -3 to 3. If no input argument is given, the default n is 49.

注:surf函数有个用法surf(z),z为一个二维矩阵,surf(z)绘制一个表面去,使用x=1:n,y=1:m, where [m n]=size[z];就是说surf(z)可以直接绘制一个表面图

例:

clc;clear;close all;
figure(1);
z=peaks(25);
surf(z);

figure(2);
peaks(5);%没有输出值的peaks函数直接绘制表面图

[x,y,z]=peaks(25);
figure(3);
surf(x,y,z);%注意图像2和图像3坐标的差异性,相当于平移了



版权声明:本文为hhhhhyyyyy8原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。