フィルターのクリア

how to randomize the column position of a matrix?

1 回表示 (過去 30 日間)
Daud
Daud 2012 年 9 月 9 日
suppose A=[D G H K ... O];
i want to do C=[H D O .... G.. K]
i also want to keep the information about the order of randomization to use it other matrix further manipulation.

採用された回答

Dishant Arora
Dishant Arora 2012 年 9 月 9 日
ind=randperm(size(A,2));
C=zeros(size(A));
C=A(:,ind);
ind preserves the order of randomization.
  2 件のコメント
Jan
Jan 2012 年 9 月 9 日
編集済み: Jan 2012 年 9 月 9 日
The pre-allocation by zeros is useless here. A pre-allocation is useful only, if the array would grow iteratively.
Dishant Arora
Dishant Arora 2012 年 9 月 9 日
Thanks jan, I must take care of it in future.

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

その他の回答 (0 件)

カテゴリ

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