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

 채택된 답변

Wayne King
Wayne King 2013년 12월 30일
편집: Wayne King 2013년 12월 30일

1 개 추천

Swapping the columns
idx = [4 2 3 1];
B = A(:,idx);
Swapping the rows
idx = [3 2 1 4];
C = A(idx,:);

추가 답변 (2개)

Daniel Morais
Daniel Morais 2017년 3월 21일

1 개 추천

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.
Sean de Wolski
Sean de Wolski 2013년 12월 30일

0 개 추천

So
A([4,1],:) = A([1,4],:)
?

카테고리

도움말 센터 및 File Exchange에서 Phased Array Design and Analysis에 대해 자세히 알아보기

태그

질문:

2013년 12월 30일

답변:

2017년 3월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by