1.plot(描点画图)

    1. x = 0:pi/100:2*pi%x为一个公差为pi/100的等差数列
    2. y = sin(x)
    3. plot(x,y)%画出正弦图像

    image.pngimage.png

    1. clear;clc;close all;
    2. hold on%两条线画在一张图上
    3. plot([0,3],[1,4]);
    4. plot([0,2.8],[1,0]);
    5. text(0,1,'A');%为图中标点

    image.png
    2.plot3

    1. clear;clc;close all;
    2. t = 0:pi/50:10*pi;
    3. st = sin(t)
    4. ct = cos(t)
    5. figure;%控制窗口数量
    6. plot3(st,ct,t)

    image.png
    3.surf

    1. %%
    2. clear;clc;close all;
    3. [X,Y] = meshgrid(1:0.5:10,1:20);%X,Y共同决定了范围内的网格点,x1:0.5:10的范围内,y1:20的范围内
    4. Z = sin(X)+cos(Y);
    5. surf(X,Y,Z)%画曲面

    image.png
    4.NaN的处理技巧

    1. clear;clc;close all;
    2. x = 0:0.01:1;
    3. [X,Y] = meshgrid(x);
    4. Z = X.^2+Y.^2;
    5. Z(Z>1) = NaN;
    6. surf(X,Y,Z);

    image.png
    5.fill

    1. %%
    2. clear;clc;close all;
    3. x = [0 1 1 0];
    4. y = [0 0 1 1];
    5. fill(x,y,'r')

    image.png