two column vector division

33 vues (au cours des 30 derniers jours)
DK
DK le 24 Avr 2019
Commenté : DK le 26 Avr 2019
%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.

Réponses (1)

Stephen23
Stephen23 le 24 Avr 2019
Modifié(e) : Stephen23 le 24 Avr 2019
"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 commentaires
DK
DK le 24 Avr 2019
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 le 26 Avr 2019
xA = B for x
x = B/A or
x=B*pinv(A)
!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Linear Algebra dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by