How can I change this into a column, at the moment all 750 entries are on one row?
p = normal(1:750)-1;
I have tried:
columns = 1;
p = normal(1:750)-1;
p = p(1:columns);
I have also tried:
rows = 1000;
p = normal(1:750)-1;
p = p(1:rows)';
Method 1 : Use reshape() method The reshape() method allows you to convert the row vector to a column vector. Here you have to just pass the two arguments. The First will be the number of columns and the second is the number of rows.
In general, the transpose of a matrix is a new matrix in which the rows and columns are interchanged. For vectors, transposing a row vector results in a column vector, and transposing a column vector results in a row vector.
A column vector is an nx1 matrix because it always has 1 column and some number of rows. A row vector is a 1xn matrix, as it has 1 row and some number of columns. This is the major difference between a column and a row vector.
In order to write a vector as a column vector: Work out the horizontal component ( x component). Work out the vertical component ( y component). Write the column vector.
Setting
p = p(:);
is indeed the best approach, because it will reliably create column vector.
Beware of the use of the '
operator to do transpose. I have seen it fail dramatically many times. The matlab operator for non-conjugate transpose is actually .'
so you would do:
p = p.'
if you want to do transpose without taking the complex conjugate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With