필터 지우기
필터 지우기

Row and Column permutation of a matrix

조회 수: 13 (최근 30일)
lilly lord
lilly lord 2020년 9월 27일
답변: madhan ravi 2020년 9월 27일
Hi I want to permute each row and column of the matrix using specified permutation
e.g
%%%%%Permute each row by a certain permutation e.g (3 2 4 1)
M=[80 81 82 83;84 85 86 87;88 89 90 91;92 93 94 95];
perm2=[3 2 4 1];
M_1=[];
b=M;
for i=1:3
b(i,perm2) = M(i,:);
M_1=[b];
end
Output should be
82 81 83 80
86 85 87 84
90 89 91 88
94 93 95 92
what I am getting is
83 81 80 82
87 85 84 86
91 89 88 90
92 93 94 95
If some one figure out the mistake plus how to permute each column wise

채택된 답변

madhan ravi
madhan ravi 2020년 9월 27일
Wanted = M(:, perm2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by