Effacer les filtres
Effacer les filtres

Rearrange matrix into single row

10 vues (au cours des 30 derniers jours)
Lanceric Tse
Lanceric Tse le 10 Août 2018
Modifié(e) : Stephen23 le 10 Août 2018
Hey there, I have a matrix that looks like this
b=1 2 3 4
1 2 3 4
1 2 3 4
What do I have to do to arrange it into a single row vector[ 1 2 3 4 1 2 3 4 1 2 3 4]?

Réponse acceptée

Paul Shoemaker
Paul Shoemaker le 10 Août 2018
reshape(b',1,numel(b)) % Note the transpose ('), this is important.
  1 commentaire
Stephen23
Stephen23 le 10 Août 2018
Modifié(e) : Stephen23 le 10 Août 2018
This answer uses complex transpose. See James Tursa's answer for the correct solution for all cases.

Connectez-vous pour commenter.

Plus de réponses (1)

James Tursa
James Tursa le 10 Août 2018
Modifié(e) : James Tursa le 10 Août 2018
result = reshape(b.',1,[]);
The transpose is needed to get the row values to line up in memory first before doing the reshape.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by