Alex Rivera | Logout

What does x = x(:) mean in matlab, where x is a vector?

Asked 2012-01-15T02:27:55.523
12

This is a hard question to google. I am new to Matlab and have seen the following statement, but I can't see how it does anything. What doe x = x(:) do?

Edit
Report

2 Answers

2

x(:) transforms the array to a column vector.

More about the colon operator

answered 2012-01-15T02:33:59.990
2

This syntax is generally used to ensure that x is a column vector:

x = x(:)

Similarly, this line ensures that x is a row vector

x = x(:)'
answered 2012-01-15T02:36:41.620

Your Answer