필터 지우기
필터 지우기

Permuting elements of matrix with a polynomial (3x^3 + 6x^2 + 7x) mod 9

조회 수: 2 (최근 30일)
Neha W
Neha W 2017년 3월 9일
댓글: Neha W 2017년 3월 10일
A = [1 2 3; 4 5 6; 7 8 9] %original position of matrix elements
[r c] = size(A); N = 9;
B = reshape(A,1,r*c); % B = [1 4 7 2 5 8 3 6 9]
I have obtained a permute vector after calculating (3x^3 + 6x^2 + 7x) mod 9 as:
per_vec = [7 8 3 1 2 6 4 5 9]; %permute vector
result = B(per_vec) %This gives me a row vector as [3 6 7 1 4 8 2 5 9]
Could you please help me understand what does B(per_vec) does?

채택된 답변

KSSV
KSSV 2017년 3월 9일
편집: KSSV 2017년 3월 9일
per_vec gives you the positions/ indices. When you use B(per_vec), it arranges the elements of B as given in per_vec. You can see it yourself by comparing B and B(per_vec)
  댓글 수: 2
Neha W
Neha W 2017년 3월 9일
Thank you Sir. I will got through it.
Neha W
Neha W 2017년 3월 10일
Sir, I got how elements got arranged acc to per_vec. Now to get original matrix A back.
dec=[3 6 7 1 4 8 2 5 9]; dec(per_vec)=dec; is implemented.
Why dec(per_vec)is written on the RHS side? Is there any logic behind it?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by