MATLAB 绘图函数用法以及简单示例
x = linspace(0, 2*pi);
y = sin(x);
plot(x, y)
t = linspace(0, 10*pi, 200);
x = sin(t);
y = cos(t);
z = t;
plot3(x, y, z)
x = randn(1, 100);
y = randn(1, 100);
scatter(x, y)
x = randn(1, 100);
y = randn(1, 100);
z = randn(1, 100);
scatter3(x, y, z)
x = categorical({'A', 'B', 'C', 'D'});
y = [1 2 3 4];
bar(x, y)
x = categorical({'A', 'B', 'C', 'D'});
y = [1 2 3 4];
barh(x, y)
x = randn(1, 1000);
histogram(x)
x = randn(1, 1000);
y = randn(1, 1000);
histogram2(x,y)
x = [1 2 3];
pie(x)
x = [1 2 3];
pie3(x)
theta = linspace(0, 2*pi);
rho = sin(theta);
polarplot(theta,rho)
polarhistogram
:在极坐标系中绘制直方图
theta = randn(1,1000);
polarhistogram(theta)
[X,Y] = meshgrid(-2:.2:2);
Z = X.*exp(-X.^2-Y.^2);
contour(X,Y,Z)
[X,Y] = meshgrid(-2:.2:2);
Z = X.*exp(-X.^2-Y.^2);
contourf(X,Y,Z)
[x,y] = meshgrid(-2:.2:2,-1:.15:1);
z = x.*exp(-x.^2-y.^2);
[px,py] = gradient(z,.2,.15);
quiver(x,y,px,py)
[x,y,z] = meshgrid(-2:.5:2,-2:.5:2,-2:.5:2);
v = x.*exp(-x.^2-y.^2-z.^2);
[px,py,pz] = gradient(v,.5,.5,.5);
quiver3(x,y,z,px,py,pz)
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
surf(X,Y,Z)
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
surfc(X,Y,Z)