Effacer les filtres
Effacer les filtres

Subtracting a Vector from a Scalar-Multiplied Matrix

1 vue (au cours des 30 derniers jours)
Athanasios Paraskevopoulos
Commenté : Paul le 5 Avr 2024
Let's say that we have the following two matrices and we want to calculate . We know that it is not defined, but MATLAB gives me the following result.Could anyone explain me why that happens?
C=[1 2; 2 1]
C = 2x2
1 2 2 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
E=[1;2]
E = 2x1
1 2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
3*C-E
ans = 2x2
2 5 4 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  5 commentaires
Athanasios Paraskevopoulos
@Torsten Yes this is my problema tha it is defined in Matlab but not in Maths.
This is what I want to show to my students
Torsten
Torsten le 5 Avr 2024
It's just a convention to get rid of the bsxfun - there is nothing to explain (or even justify).

Connectez-vous pour commenter.

Réponse acceptée

Steven Lord
Steven Lord le 4 Avr 2024
  8 commentaires
Athanasios Paraskevopoulos
Oh ok!! Now it is all clear! Thank you!
Paul
Paul le 5 Avr 2024
Even prior to R2016B, as far back as to the very first release as far as I know, Matlab implemented scalar expansion. Code like this has always worked
eye(2) - 1
ans = 2x2
0 -1 -1 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
even though subtracting a scalar from a matrix is not mathematically rigorous.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by