フィルターのクリア

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

1 回表示 (過去 30 日間)
Furqan Haider
Furqan Haider 2014 年 1 月 17 日
コメント済み: Furqan Haider 2014 年 1 月 17 日
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,[])
  1 件のコメント
Furqan Haider
Furqan Haider 2014 年 1 月 17 日
Thank u, i needed the 2nd suggestion.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by