Rearrange matrix into single row
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Lanceric Tse
il 10 Ago 2018
Modificato: Stephen23
il 10 Ago 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]?
0 Commenti
Risposta accettata
Paul Shoemaker
il 10 Ago 2018
reshape(b',1,numel(b)) % Note the transpose ('), this is important.
1 Commento
Stephen23
il 10 Ago 2018
Modificato: Stephen23
il 10 Ago 2018
This answer uses complex transpose. See James Tursa's answer for the correct solution for all cases.
Più risposte (1)
James Tursa
il 10 Ago 2018
Modificato: James Tursa
il 10 Ago 2018
result = reshape(b.',1,[]);
The transpose is needed to get the row values to line up in memory first before doing the reshape.
0 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!