how do i turn an array into a column vector?

574 ビュー (過去 30 日間)
Tom
Tom 2012 年 5 月 23 日
移動済み: Stephen23 2025 年 2 月 13 日 6:21
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 件のコメント
Jan
Jan 2012 年 5 月 24 日
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.
Matt Fig
Matt Fig 2012 年 11 月 2 日
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?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 5 月 23 日
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 件のコメント
Tom
Tom 2012 年 5 月 24 日
great thanks walter this is exactly what i needed :)
Andre
Andre 2025 年 2 月 13 日 5:55
移動済み: Stephen23 2025 年 2 月 13 日 6:21
Thanks Walter; works perfectly.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by