how do i turn an array into a column vector?

I can't work out how to change my array into a column vector. I thought it was just putting ' after it, but that's not working. If I had A=[1,2,3,4] how would I make that into a 4x1 column vector?

2 Comments

For "A = [1,2,3,4]" inserting a ' afterwards is sufficient:
A = [1,2,3,4]'
or:
A = [1,2,3,4]; disp(A');
If this does not work for your code, please post the code and the error message.
I can't work out how to change my array into a column vector. I thought it was just putting ' after it, but that's not working. If I had A=[1,2,3,4] how would I make that into a 4x1 column vector?

Sign in to comment.

 Accepted Answer

For any kind of array you get a single column vector by
A(:)
Or if you are sure that A is a row vector,
A.'
Caution: A' is the conjugate transpose and the plain transpose is A.'

2 Comments

great thanks walter this is exactly what i needed :)
Andre
Andre on 13 Feb 2025
Moved: Stephen23 on 13 Feb 2025
Thanks Walter; works perfectly.

Sign in to comment.

More Answers (0)

Products

Asked:

Tom
on 23 May 2012

Moved:

on 13 Feb 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!