Permuting elements of matrix with a polynomial (3x^3 + 6x^2 + 7x) mod 9
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Neha W
el 9 de Mzo. de 2017
Comentada: Neha W
el 10 de Mzo. de 2017
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?
0 comentarios
Respuesta aceptada
KSSV
el 9 de Mzo. de 2017
Editada: KSSV
el 9 de Mzo. de 2017
You have to read about matlab's matrix indexing first. https://in.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Polynomials en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!