📅  最后修改于: 2021-01-07 03:19:04             🧑  作者: Mango
目的:研究矩阵的算术运算,矩阵的关系运算和矩阵的逻辑运算。
Operations | MATLAB Form | Comments |
---|---|---|
Array Addition |
a+b | Array & matrix addition are identical |
Array Subtraction | a-b | Array & matrix subtraction are identical |
Array Multiplication | a.*b | Array multiplication element by element multiplication of a & b |
Matrix Multiplication | a*b | For matrix multiplication no of a column in matrix a=no of a column of matrix b |
Array Right Division | a./b | Element by element division of a & b |
Array Left Division | a.\b | Element by element division of a & b within the Numerator. |
Matrix Right Division | a/ba* | inv(b) where inv represent inverse |
Matrix Left Division | a\b | inv(a)*b |
Array Exponential | a.^b | Element by element exponential of a & b i.e a(i , j) ^ b( i , j) |
>>b=[4,5;6,7]
b =
4 5
6 7
>> c= [5,8;9,8]
c =
5 8
9 8
>> b+c
ans =
9 13
15 15
>> b-c
ans =
-1 -3
-3 -1
>> b.^c
ans =
1024 390625
10077696 5764801
>> b./c
ans =
0.8000 0.6250
0.6667 0.8750
>> b.\c
ans =
1.2500 1.6000
1.5000 1.1429
关系运算符用于表示条件,例如“ space?0”和“ result?25”。它们采用两个数字(或字符串)操作数。它们产生逻辑结果(对或错)。
通用形式为:a1 op a2
a1和a2是算术表达式,变量或字符串。
op是以下之一
Operators | Operations |
---|---|
== | Equal to |
~= | Not equal to |
> | Greater than |
>= | Greater than equal to |
< | Less than |
<= | Less than equal to |
>>b=[4,5;6,7]
b =
4 5
6 7
>> c=[5,8;9,8]
c =
5 8
9 8
>> b>c
ans =
0 0
0 0
>> c>b
ans =
1 1
1 1
>> c==b
ans =
0 0
0 0
>> 'd'<'a'
ans =
0
>> e=7
e =
7
>> f=6
f =
6
>> e&&f
ans =
1
>> e||f
ans =
1
>> g=0
g =
0
>> e&&g
ans =
0
>> f||g
ans =
1
>> xor(e,f)
ans =
0
>>b=[4,5;6,7]
b =
4 5
6 7
>> c=[5,8;9,8]
c =
5 8
9 8
>> b&c
ans =
1 1
1 1
>> b|c
ans =
1 1
1 1
>> xor(b,c)
ans =
0 0
0 0
>> ~b
ans =
0 0
0 0
>> ischar(g)
ans =
0
>> b
b =
4 5
6 7
>> logical(b)
ans =
1 1
0 1
>> n='y'
n =
y
>> ischar(n)
ans =
1
>> isempty(n)
ans =
0
>> isnumeric(n)
ans =
0
>> y=1234
y =
1234
>> isnumeric(y)
ans =
1