Effacer les filtres
Effacer les filtres

How can I rearrange all row elements into a single row?

1 vue (au cours des 30 derniers jours)
Furqan Haider
Furqan Haider le 17 Jan 2014
Commenté : Furqan Haider le 17 Jan 2014
I have a matrix, m*n ,
b =
0011
1110
1100
0000
1101
0010
0111
1011
0011
0011
now i want to make a row matrix of size [1*(m*n)] or [1*40] in the above case, where elements of each row are put next to previous row: i.e.
d= [row(1)of b row(2) of b row(3) of b and so on]
i have tried reshape function, but it reshapes the matrix column wise. Kindly help

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 17 Jan 2014
Modifié(e) : Azzi Abdelmalek le 17 Jan 2014
b=[0 0 1 1;1 1 1 0; 1 1 0 0;0 0 0 0]
b=b(:)'
%or maybe you want
b=[0 0 1 1;1 1 1 0; 1 1 0 0;0 0 0 0]
b=b'
b=b(:)'
It's good also to know that you can do it with reshape function
b=[0 0 1 1;1 1 1 0; 1 1 0 0;0 0 0 0]
reshape(b',1,[])

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by