A = [1 : 3 ; 4 : 6]
A = zeros(2 , 3) 注:两行三列0矩阵
A = eye(3 , 3)
t = 0 : 1 : 5 注:行向量,但如果步长为1的话,可省略,因为默认为1
A * B’注: ’代表转置
c = a\b 注:左除,ax = b的解
c = a/b 注:右除,xa = b的解
diag:提取对角元素
A = [1,2,3;4,5,6]
D = diag(A)
D1 = diag(A , 1)
D1 = diag(A , -1)
diag([1,2,-1,4])
diag(1 : 3 , -1)
%三角阵
上三角阵:
B1 = triu(A)
B2 = triu(A , 2) 注:以第二条对角线为基准
B1 = triu(A)
A = [7 13 -28 ; 2 -9 8 ; 0 34 5]
B1 =
7 13 -28
0 -9 8
0 0 5
B2 = triu(A , 2)
B2 =
0 0 -28
0 0 0
0 0 0
%矩阵转置
B = A’
%矩阵旋转
B = rot90(A) 注:逆时针旋转90度
rot90(A , 4) 注:按逆时针旋转4次90度
%矩阵翻转
B = fliplr(A) 注:左右翻转(C1列与Cn列交换,C2列与Cn-1列交换)
B = flipud(A) 注:上下翻转(r1行与rn行列交换,r2行列与rn-1行列交换)
%矩阵特征参数
%行列式
D = [3 4 5;1 2 3;3 6 9]
det(D) = 0
%矩阵的秩
A = (1 -2 1;3 4 5;-2 1 7)
b = [12 ; 20 ; 11]
C = [A b]
rank(A)
rank(C)
x = A\b
A = [1 -2 1 ; 3 4 5 ; -2 1 7];
b = [12 ; 20 ; 11];
C = [A b]
C =
1 -2 1 12
3 4 5 20
-2 1 7 11
rank(A)
ans =
3
rank(C)
ans =
3
x = A\b
x =
4.3958
-2.2292
3.1458
%特征值、特征向量
A = [3 -1;-1 3]
eig(A)
[v , d] = eig(A)
A = [3 -1 ; -1 3];
eig(A)
ans =
2
4
[v , d] = eig(A)
v =
-0.7071 -0.7071
-0.7071 0.7071
d =
2 0
0 4
%矩阵的逆
inv(A)
A = [3 -1 ; -1 3];
inv(A)
ans =
0.3750 0.1250
0.1250 0.3750
请发表评论