本文为本人学习Matlab基础知识是做的一些笔记,希望可以对大家有所帮助 (>_<)
p.s. 英文来自于Matlab帮助文档
- … 表示 指令的续行输入。
- 矩阵的输入:
a) A = [1, 2, 3; 4, 5, 6; 7, 8, 9]
b) A = [1, 2, 3
4, 5, 6
7, 8, 9]
3. 复数: z = 3 + 4i
a) real() 复数的实部Real part of complex number
b) imag() 复数的虚部Imaginary part of complex number
c) angle() 复数的幅角( z=r*(cosθ + i sinθ) )This MATLAB function returnsthe phase angles, in radians, for each element of complex array Z.
d) abs() 复数的模
4. exp(x) e的x次方
5. abs – 绝对值和复数的模(Absolutevalue and complex magnitude)
6. grid() 加网格
gridon adds major grid lines to the current axes.
gridoff removes all grid lines from the current axes.
grid toggles the visibility of the major grid lines of the current axes.
gridminor toggles the visibility of the minor gridlines of the current axes.
grid(axes_handle,...)uses the axes specified by axes_handle instead ofthe current axes.
7. plot 绘制二维网格 2-D line plot
plot(X,Y)
plot(X,Y,LineSpec)
- If X and Y are bothvectors, then they must have equal length and MATLAB plots Y versus X.
- If X and Y are bothmatrices, then they must have equal size and MATLAB plots columns of Y versuscolumns of X.
- If one of X or Y is avector and the other is a matrix, then the matrix must have dimensions suchthat one of its dimensions equals the vector length. If the number of matrixrows equals the vector length, then MATLAB plots each matrix column versus thevector. If the number of matrix columns equals the vector length, then MATLABplots each matrix row versus the vector. If the matrix is square, then MATLABplots each column versus the vector.
- If one of X or Y is a scalarand the other is a vector, then MATLAB plots the vector as discrete points atthe scalar value.
plot(X1,Y1,...,Xn,Yn)
plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn)
plot(Y)
If Y is a vector, then thex-axis scale ranges from 1 to length(Y).
If Y is a matrix, thenMATLAB plots the columns of Y versus their row number. The x-axis scale rangesfrom 1 to the number of rows in Y.
If Y is complex, thenMATLAB plots the imaginary part of Y versus the real part of Y, such thatplot(Y) is equivalent to plot(real(Y),imag(Y)).
plot(Y,LineSpec)
plot(___,Name,Value)
plot(axes_handle,___)
h = plot(___)
8. A’ 矩阵A的转置
9. ones 新建值均为1的数组Create array of all ones
X = ones
X= ones(n)
X= ones(sz1,...,szN)
X= ones(sz)
X= ones(classname)
X= ones(n,classname)
X= ones(sz1,...,szN,classname)
X= ones(sz,classname)
X= ones(‘like‘,p)
X= ones(n,‘like‘,p)
X= ones(sz1,...,szN,‘like‘,p)
X =ones(sz,‘like‘,p)
10. .* 两个矩阵中各个元素进行乘法运算 (加 . 表数值上的)
* 严格的矩阵乘法
11. eps - Floating-point relativeaccuracy [ eps = 2^(-52) ]
12. surf - 3-D shaded surface plot
This MATLAB function creates a three-dimensional shaded surface from thez
components in matrix Z, using x = 1:n and y = 1:m, where [m,n] =size(Z).
surf(Z)
surf(Z,C)
surf(X,Y,Z)
surf(X,Y,Z,C)
surf(...,‘PropertyName‘,PropertyValue)
surf(axes_handles,...)
h = surf(...)