How to extract a row from a transpose of a matrix

8 ビュー (過去 30 日間)
Chamira Wickramasinghe
Chamira Wickramasinghe 2017 年 9 月 26 日
編集済み: Jan 2017 年 9 月 26 日
Hi,
Say I do have a matrix M=[1 2; 3 4; 5 6]
And say that I want to extract the first row from the transpose of the M matrix
Without saving the transpose of M as another matrix like doing like M_trans = M' and k = M_trans(1,:)
How to do it in a one line??
M'(1,:) won't work

回答 (1 件)

Cedric
Cedric 2017 年 9 月 26 日
Take the first column of the original matrix.
  3 件のコメント
Cedric
Cedric 2017 年 9 月 26 日
編集済み: Cedric 2017 年 9 月 26 日
My pleasure! Don't forget to accept the answer if it helped.
In MATLAB there is not easy way to index the output of a function, here TRANSPOSE .', or complex conjugate transpose as you write it '.
Jan
Jan 2017 年 9 月 26 日
編集済み: Jan 2017 年 9 月 26 日
@Chamira: Cedric is right: You cannot get the transpose on the fly by telling Matlab magically, that you do not want to create the transposed explicitly, to extract a subvector. There are 2 ways only:
  1. Create the transposed explicitly: MT = M'; k = MT(1,:)
  2. Create your own algorithm, which extract directly, what you need: k = M(:,1).'.
The work must be accomplished anywhere: Either in Matlab by calculating the complete transposed matrix, although only a part is needed, or inside your brain, such that the indirection over the transposition is omitted. But there is no smart way to let Matlab perform the task of thinking.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by