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

1 次查看(过去 30 天)
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

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-1-17
编辑:Azzi Abdelmalek 2014-1-17
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,[])

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by