Effacer les filtres
Effacer les filtres

Use of ":"operator in matlab?

4 vues (au cours des 30 derniers jours)
ABTJ
ABTJ le 21 Juin 2020
Modifié(e) : Stephen23 le 23 Juin 2020
Let say i have a matrix; x=[2 3;4 5] % 2 rows 2 columns
then i enter command , x(:)=[2;3;4;5] % 4 rows 1 column
What is happening here?
Is there any possiblity that i get 1 row 4 columns?If yes,how?

Réponse acceptée

madhan ravi
madhan ravi le 21 Juin 2020
(:) forces the matrix to a column vector, all you need is
reshape(matrix, 1, [])
  2 commentaires
Stephen23
Stephen23 le 23 Juin 2020
Modifié(e) : Stephen23 le 23 Juin 2020
"(:) forces the matrix to a column vector"
Only when used in an expression or the RHS of an assignment. On the LHS it simply refers to all elements of the array (in linear index order) and does not change the size or shape of the LHS array at all. See:
madhan ravi
madhan ravi le 23 Juin 2020
Modifié(e) : madhan ravi le 23 Juin 2020
“Only when used on the RHS of an assignment”
Exactly what the OP was asking and I was referring too. Was expecting your comment a bit earlier though ;). But thank you for explaining the details.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by