two column vector division

34 ビュー (過去 30 日間)
DK
DK 2019 年 4 月 24 日
コメント済み: DK 2019 年 4 月 26 日
%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.

回答 (1 件)

Stephen23
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?"
See the mldivide help for a list of the algorithms used.
"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
  • 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.
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.
  4 件のコメント
DK
DK 2019 年 4 月 24 日
good to understand xA = B for x by using B/A (mrdivide)!
any matrix represention of B/A?
I tried inv(diag(B)).*A, but it doesn't work. In case, B is not inversible...
DK
DK 2019 年 4 月 26 日
xA = B for x
x = B/A or
x=B*pinv(A)
!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by