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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by