Question Regarding Division Operation
1 view (last 30 days)
Show older comments
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]
0 Comments
Answers (1)
James Tursa
on 9 Oct 2017
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
0 Comments
See Also
Categories
Find more on Mathematics and Optimization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!