Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 17 Jan. 2014
Bearbeitet: Azzi Abdelmalek am 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,[])

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by