Question Regarding Division Operation

3 次查看(过去 30 天)
Why does a/b gives a 3x3 matrix instead of giving an error for the following example? What Operation is it Performing?
a = [1 2;3 4;5 6] and b = [3 4; 5 6;7 8]
a./b = [0.33 0.5;0.60 0.66;0.7143 0.75] and a/b = [1.5 0 -0.5;1 0 0;0.5 0 0.5]

回答(1 个)

James Tursa
James Tursa 2017-10-9
Using the ./ operator with the dot does element-wise division. Using / without the dot does matrix linear equation solving. So this operation:
x = a/b
is the solution to the following equation
x*b = a
I.e., conceptually you divide both sides of this equation on the right by b to get the solution above. This is simply a set of linear equations that MATLAB is solving using the "backslash" or "forwardslash" operator. E.g.,
>> a = [1 2;3 4;5 6]
a =
1 2
3 4
5 6
>> b = [3 4; 5 6;7 8]
b =
3 4
5 6
7 8
>> x = a/b
x =
1.5000 0 -0.5000
1.0000 0 0
0.5000 0 0.5000
>> x*b
ans =
1.0000 2.0000
3.0000 4.0000
5.0000 6.0000

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by