MATLAB二维平面绘图

plot - 2-D line plot

    This MATLAB function creates a 2-D line plot of the data in Y versus the
    corresponding values in X.If X and Y are both vectors, then they must have equal
    length and MATLAB plots Y versus X.If X and Y are both matrices, then they must
    have equal size and MATLAB plots columns of Y versus columns of X.If one of X or
    Y is a vector and the other is a matrix, then the matrix must have dimensions
    such that one of its dimensions equals the vector length.

    plot(X,Y)
    plot(X,Y,LineSpec)
    plot(X1,Y1,...,Xn,Yn)
    plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn)
    plot(Y)
    plot(Y,LineSpec)
    plot(___,Name,Value)
    plot(axes_handle,___)
    h = plot(___)
注释:
对于X和Y,可以有以下几种参数形式
(1)X是向量(行向量或列向量),Y是向量(行向量或列向量),并且length(x)==length(y)。
(2)X,Y是M*N的矩阵,Y中的每一列元素为纵坐标,绘制N条曲线。第一条曲线我的坐标为:[x11,y11],[x12,y12],..[x1M,y1M]
(3)X是向量,Y是函数。绘制出Y=F(X)的函数图。
举例1:
x=[1,3,5,6]
y=[0.1,0.2,0.3,0.4]
plot(x,y)
举例2:
x=[1,5,9;2,4,8]
y=x
plot(x,y)
%绘制出三段曲线
第一段曲线:(1,1),(2,2)
第二段曲线:(5,5),(4,4)
第三段曲线:(8,8),(9,9)

举例3:
x=[0:pi/10:2*pi]  %[0,2*pi]间隔为pi/10的向量
y-sin(x)
plot(x,y)

添加图像标题:title('标题')

添加横坐标提示: xlabel('横坐标提示')

添加纵坐标提示: ylabel('纵坐标提示')

在坐标位置添加提示:text(x,y,'提示')  %x为横坐标,y为纵坐标

 绘制网格    grid

LineSpec用字符串来表示,例如'-.'代表点和实线,'-.*'代表实现实线,点,星号

原文地址:https://www.cnblogs.com/codeDog123/p/6269638.html