其他分享
首页 > 其他分享> > Using MATLAB in Linear Algebra (1)

Using MATLAB in Linear Algebra (1)

作者:互联网

MATLAB Cookbook

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

标签:3.0000,Linear,Algebra,1.0000,MATLAB,ans,operator,Using,2.0000
来源: https://www.cnblogs.com/BME-Shawn/p/13197413.html