How to permute the rows and columns in a matrix ?
    조회 수: 32 (최근 30일)
  
       이전 댓글 표시
    
for example: I have matrix A: A = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16] how to permute between column 1 and column 4 ? how to permute between row 1 and row 3 ? thanks
댓글 수: 0
채택된 답변
  Wayne King
    
      
 2013년 12월 30일
        
      편집: Wayne King
    
      
 2013년 12월 30일
  
      Swapping the columns
 idx = [4 2 3 1];
 B = A(:,idx);
Swapping the rows
 idx = [3 2 1 4];
 C = A(idx,:);
댓글 수: 0
추가 답변 (2개)
  Daniel Morais
 2017년 3월 21일
        Utilize x = x( : , randperm(c)), onde x é a matriz e c o número de colunas de x. O mesmo vale para a permutação de linhas: x = x( randperm(l) , : ) onde l é o número de linhas.
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



