Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change row vector to column vector

Tags:

vector

matlab

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)';
like image 207
G Gr Avatar asked Nov 16 '12 09:11

G Gr


People also ask

How do you transpose a row vector to a column vector in Python?

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.

Is the transpose of a row vector a column vector?

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.

Is a row vector the same as a column 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.

How do you write a vector vector to a column?

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.


1 Answers

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.

like image 119
Ru887321 Avatar answered Oct 21 '22 11:10

Ru887321