How to reshape the columns of a matrix into one row?
35 次查看(过去 30 天)
显示 更早的评论
Hello,
please I need help in this:
suppose that we have a (3*4) matrix that have only binary values either 0 or 1, now I need to read this matrix column by column from the top of the column to the bottom. And I concatenate the values of each column with the values of the other columns. So how can I do that?
for example the matrix A= [
0 1 1 1
1 0 1 0
1 0 0 1
]
the ouput of this process hsould be = 011100110101
Regards,
0 个评论
采纳的回答
Guillaume
2019-9-5
It's not clear what it is you want as an output. If it's a row vector, there's no concatenation involved, you just simply reshape your matrix:
A = [0 1 1 1;
1 0 1 0;
1 0 0 1]
v = reshape(A, 1, []) %reshape A into one row. Since matlab is column major, this is done column-wise
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!