MATLAB Answers

# How to reshape the columns of a matrix into one row?

24 views (last 30 days)
Sarah A on 5 Sep 2019
Edited: Sarah A on 5 Sep 2019
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 Comments

Sign in to comment.

### Accepted Answer

Guillaume on 5 Sep 2019
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

#### 1 Comment

Sarah A on 5 Sep 2019
yes it reshape. thank you.

Sign in to comment.

### More Answers (0)

Sign in to answer this question.

Translated by