MATLAB Notes
Language Fundamentals
Entering Commands
- clc : clear command window
Matrices and Arrays
- x = j:k : [j, j+1, …, k]
- x = j:i:k : [j, j+i, …, k]
- zeros : zeros array
Operators and Elementary Operations
Arithmetic
Data Types
Numeric Types
Mathematics
Elementary Math
Trigonometry
Exponents and Logarithms
Complex Numbers
Graphics
2-D and 3-D Plots
Line Plots
- loglog() : log-log scale plot
- plot(X,Y) : linear plot
- plot3(x,y,z) : plot lines and points in 3-D space
- semilogx() : semi-log scale plot
- semilogy() : semi-log scale plot
- '+' : plus sign
- 'o' : circle
- '*' : asterisk(星號)
- '.' : point
- 'x' : cross
- 'square' or 's' : square
- 'diamond' or 'd' : diamond
- '^' : upward-pointing triangle
- 'v' : downward-pointing triangle
- '>' : right-pointing triangle
- '<' : left-pointing triangle
- 'pentagram' or 'p' : five-pointed star (pentagram)
- 'hexagram' or 'h' : six-pointed star (hexagram)
- 'r' : red
- 'g' : green
- 'b' : blue
- 'c' : cyan(青)
- 'm' : magenta(洋紅)
- 'y' : yellow
- 'k' : black
- 'w' : white
Discrete Data Plots
- stem(X,Y) : discrete sequence or "stem" plot
Titles and Labels
- legend(label1,…,labelN) : (圖例)
- title('text') : graph title
- xlabel('text') : X-axis label
- ylabel('text') : Y-axis label
- zlabel('text') : Z-axis label
Axes Appearance
- axis() : control axis scaling and appearance
- axis([XMIN XMAX YMIN YMAX])
- figure() : create figure window
- hold : hold current graph
- subplot() : create axes in tiled(鋪) positions
- subplot(m,n,p)
- subplot(mnp)
Graphics Objects
Graphics Object Programming
- close : close figure
- close all : closes all the open figure windows
Data Import and Analysis
Data Import and Export
Workspace Variables and MAT-Files
- clear : clear variables and functions from memory
Others
- heaviside(X) : step function
- phase(G) : computes the phase of a complex vector
- rectpuls(T,W) : sampled aperiodic rectangle generator
Homepage