two column vector division

조회 수: 33 (최근 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 CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by