Mapping a smaller matrix to a larger matrix

14 vues (au cours des 30 derniers jours)
Aaron DeSantis
Aaron DeSantis le 23 Fév 2023
Commenté : Aaron DeSantis le 23 Fév 2023
I have a 4x4 matrix with indicies indicated around it (k). I want to map it to an 8x8 matrix based on thoes indicies to give me k'. See the image below for clarification. Is there a way to do it such that the indecies on the 4x4 matric and be any value from 1-8. For instance instead of 7812, use 4312 or 4378.
  2 commentaires
Dyuman Joshi
Dyuman Joshi le 23 Fév 2023
How are the indices given to you? Or how are these indices provided to the code as input?
Jan
Jan le 23 Fév 2023
A smarter example than only 1
K = [1,2,3,4; 5,6,7,8; 9,10,11,12; 13,14,15,16];
index1 = [7,8,1,2];
index2 = [7,8,1,2];

Connectez-vous pour commenter.

Réponse acceptée

Cameron
Cameron le 23 Fév 2023
Modifié(e) : Cameron le 23 Fév 2023
k = ones(4);
kprime = zeros(8);
krow = [7 8 1 2];
kcol = [7; 8; 1; 2];
kprime(krow,kcol) = k;
Not sure where the k'(5,1) value came from or if you accidentally put a 1 there.
  1 commentaire
Aaron DeSantis
Aaron DeSantis le 23 Fév 2023
You are correct. The 1 at k(5,1) is an error and is supposed to be a zero.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by