Effacer les filtres
Effacer les filtres

I receive different output to like input

1 vue (au cours des 30 derniers jours)
omri dagan
omri dagan le 1 Nov 2022
why is there diffrent in the outputs?
v=0:4;[0:4+5*(0:4)'];[v+5*v']
  1 commentaire
Gautam Chettiar
Gautam Chettiar le 1 Nov 2022
v' is the transpose, and when you are adding two 1-D arrays which have different dimensions, here of (1,5) and (5,1), MATLAB automatically casts a broadcasted matrix addition, hence both of matrices get converted to (5,5) dimension form with repeating columns and rows respectively. The output is exactly what it should be.

Connectez-vous pour commenter.

Réponse acceptée

Voss
Voss le 1 Nov 2022
0:4+5*(0:4)' is the same as 0:(4+5*(0:4)')
0:(4+5*(0:4)')
ans = 1×5
0 1 2 3 4
v+5*v', where v is 0:4, is the same as (0:4)+5*(0:4)'
v = 0:4;
v+5*v'
ans = 5×5
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
(0:4)+5*(0:4)'
ans = 5×5
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by