Effacer les filtres
Effacer les filtres

Reshape a vector to a matrix

64 vues (au cours des 30 derniers jours)
Nicolas Guerrero Naranjo
Nicolas Guerrero Naranjo le 18 Août 2021
Commenté : darova le 21 Août 2021
Hello, I have the following doubt imagining that I have the vector
x=[1 2 3 4 5 6 7 8 9 10]
how can I do to reorganize it as follows
A=[1 2 3 4 5
6 7 8 9 10]
Since as we know reshape organizes as follows.
A=[1 3 5 7 9
2 4 6 8 10]
Thank u so much in advance.
  1 commentaire
Star Strider
Star Strider le 18 Août 2021
This seems to be homework.
In any event, just use the reshape function.
.

Connectez-vous pour commenter.

Réponse acceptée

Wan Ji
Wan Ji le 18 Août 2021
Modifié(e) : Wan Ji le 18 Août 2021
Just use reshape and transpose it!
x=[1 2 3 4 5 6 7 8 9 10] ;
A = reshape(x, 5, 2)'
Then we get
A =
1 2 3 4 5
6 7 8 9 10
This skill will usually be used in practical matlab programming
  5 commentaires
Wan Ji
Wan Ji le 21 Août 2021
thsnk you, darova!
darova
darova le 21 Août 2021
my pleasure

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by