plot

  • For examples, see Matlab Graphics - Line Plots.

  • plot(X,Y) creates a 2-D line plot of the data in Y versus the corresponding values in X

    • If X and Y are both vectors, they must have equal length
    • If X and Y are both matrices, they must have equal size, and plot plots columns of Y versus columns of X
    • If one of X or Y is a vector and the other is a matrix, the matrix must have a dimension whose size equals the length of the vector
      • If the number of matrix rows equals the vector length, plot plots each matrix column versus the vector
      • If the number of matrix columns equals the vector length, plot plots each matrix row versus the vector
      • If the matrix is square, plot plots each column versus the vector
    • If one of X or Y is a scalar and the other is a scalar or a vector, plot plots discrete points
      • You must specify a marker symbol to see those points
  • plot(X,Y,LineSpec) sets the appearance of the plot via LineSpec

    • LineSpec is a char vector combining
      • line style
      • marker symbol
      • color
    • The components are unordered, and not all three need be present
    • For example: -.or, db, --mo
  • plot(X1,Y1,...,Xn,Yn) plots multiple X, Y pairs in the same axes

  • plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn) sets line style, marker type, and color for each line

    • You can mix X, Y, LineSpec triplets with bare X, Y pairs, as in plot(X1,Y1,X2,Y2,LineSpec2,X3,Y3)
  • plot(Y) creates a 2-D line plot of the data in Y versus the index of each value

    • If Y is a vector, the x-axis ranges from 1 to length(Y)
    • If Y is a matrix, plot plots the columns of Y versus their row numbers; the x-axis ranges from 1 to the number of rows
    • If Y is complex, plot plots the imaginary part versus the real part
      • In this case plot(Y) is equivalent to plot(real(Y),imag(Y))
  • plot(Y,LineSpec) sets line style, marker symbol, and color

  • plot(___,Name,Value) specifies line properties using one or more Name,Value pair arguments

    • Name-value settings apply to every line plotted
  • plot(ax,___) plots into the axes specified by ax instead of the current axes (gca) !tocheck

  • h = plot(___) returns a column vector of chart line objects