MATLAB: Matrix[1,1​,1,1;-1,-1​,-1,-1;1,1​,1,1] to vector[1,1​,1,1,-1,-1​,-1,-1,1,1​,1,1]

matrix to vector

Matrix[1,1,1,1;-1,-1,-1,-1;1,1,1,1] to vector[1,1,1,1,-1,-1,-1,-1,1,1,1,1] How can I code?

Best Answer

I believe you intended semicolons (;) instead of colons (:) in your matrix definition.
To convert it to a vector, use the reshape function:
Matrix = [1,1,1,1; -1,-1,-1,-1; 1,1,1,1];
Vector = reshape(Matrix', 1, [])
Vector =
1 1 1 1 -1 -1 -1 -1 1 1 1 1
EDIT — Added output of ‘Vector’.