How to combine multiple columns into a single column?
35 ビュー (過去 30 日間)
古いコメントを表示
I have a dataset of 12 rows and 163 columns, but how can I make convert it into a single column? e.g., [1 2 3 4; 5 6 7 8; 9 1 2 3; 4 5 6 7; 8 9 1 2; 3 4 5 6]
This is a 6x4 matrix, how can convert it to a single column like 1 5 9 4 8 3 2 6 1 5 9 4 3 7 2 6 1 5 4 8 3 7 2 6
But note that I have 163 columns in reality, so is there any general method to convert 163 columns to a single column? Thanks.
1 件のコメント
malladi siva kumari
2019 年 10 月 21 日
In simple way....
variable (a) = [ [1 2 3 4; 5 6 7 8; 9 1 2 3; 4 5 6 7; 8 9 1 2; 3 4 5 6]]
a =
1 2 3 4
5 6 7 8
9 1 2 3
4 5 6 7
8 9 1 2
3 4 5 6
alinear = a(:)
alinear =
1
5
9
4
8
3
2
6
1
5
9
4
3
7
2
6
1
5
4
8
3
7
2
6
採用された回答
Azzi Abdelmalek
2014 年 4 月 18 日
編集済み: Azzi Abdelmalek
2014 年 4 月 18 日
A=[ 1 2 3 4
5 6 7 8
9 1 2 3]
out=A(:)
or
out=reshape(A,[],1)
その他の回答 (2 件)
Mischa Kim
2014 年 4 月 18 日
編集済み: Mischa Kim
2014 年 4 月 18 日
datacol = reshape(data, 12*163, [])
1 件のコメント
SARA Hosseini
2018 年 9 月 20 日
How to do it for 3*1000 matrix an I want the 3 rows be in just one row for example if it is A=[1 2 3; 4 5 6; 7 8 9 ... ] I want it to be B=[1 2 3 4 5 6 7 8 9 10 .....]
Shubham Gorule
2020 年 9 月 3 日
let matrix be A then perform following steps
X=A(:)
Y=X'
you wil get desired result assigned to variable Y.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!