Using MATLAB in Linear Algebra (1)
阿新 • • 發佈:2020-06-27
目錄
MATLAB Cookbook
- 該筆記整理自Using MATLAB in Linear Algebra, Edward Neuman Department of Mathematics Southern Illinois University at Carbondale
Linear Algebra
共軛轉置 '
>> a = [1 2 3];
>> b = [1;2;3];
>> (a+i*b')'
ans =
1.0000 - 1.0000i
2.0000 - 2.0000i
3.0000 - 3.0000i
轉置.'
>> a = [1 2 3];
>> b = [1;2;3];
>> (a+i*b').'
ans =
1.0000 + 1.0000i
2.0000 + 2.0000i
3.0000 + 3.0000i
【如何】得到向量中的元素個數?
length(a)
>> a = [1 2 3]; >> length(a) ans = 3
使用
.
來表示分量components之間的運算It is used for the componentwise application of the operator that follows the dot operator
dot product 點乘
>> a = [1 2 3];
>> b = [1;2;3];
>> a*b
ans =
14
outer product 外積
>> a = [1 2 3]; >> b = [1;2;3]; >> b*a ans = 1 2 3 2 4 6 3 6 9
cross product 叉乘
>> a = [1;2;3];
>> b = [-2 1 2];
>> cross(a,b)
ans =
1 -8 5
>> a = [1 2 3];
>> b = [-2 1 2];
>> cross(a,b)
ans =
1 -8 5
% 無論是列向量還是行向量,結果都一樣
extract submatrix 擷取矩陣
% To extract a submatrix
>> A = [1 2 3;4 5 6;7 8 10];
>> B = A([1 3],[1 2]) % 選取第1,3行,1,2列,得到由該行列所選中的元素組成的矩陣
B =
1 2
7 8
row interchanging 行交換
% 使用 : 來選中所有列,重新選取特定行組成新的矩陣。
>> A = [1 2 3;4 5 6;7 8 10];
>> C = A([3 2 1],:)
C =
7 8 10
4 5 6
1 2 3
- The colon operator : stands for all columns or all rows.