- row vectors of size 1xN then I would expect to get a 1x1 output.
- column vectors of size Nx1 then I would expect to get an NxN output.
two column vector division
25 次查看(过去 30 天)
显示 更早的评论
%two column vector division
a = [1 2 3 0 0 0 4 5 6];
b = [2 4 6 0 0 0 8 10 12];
a/b
%two column vector division without zero
aa = [1 2 3 4 5 6];
bb = [2 4 6 8 10 12];
aa/bb
What is a mathematical formula? It doesn't work with two row vectors with the division. Why?
Thank you!
DK.
0 个评论
回答(1 个)
Stephen23
2019-4-24
编辑:Stephen23
2019-4-24
"two column vector division"
All of your examples use row vectors, not column vectors.
"What is a mathematical formula?"
"It doesn't work with two row vectors with the division"
Yes, it does work: it solves that system of linear equations, exactly like its help states. Following standard rules for solving systems of linear equations, if both arguments are
And that is exactly what we do get:
>> [1,2,3] / [4,5,6]
ans = 0.41558
>> [1;2;3] / [4;5;6]
ans =
0.051948 0.064935 0.077922
0.103896 0.129870 0.155844
0.155844 0.194805 0.233766
"Why a/b and mean(a)/mean(b) are different?"
The documentation clearly states that for a scalar first argument mrdivide is equivalent to rdivide (i.e. divides the first argument by the second), so your example with mean simply divides values. All of your other examples solve systems of linear equations.
If you are doing two different operations, then two different outputs is to be expected.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!