How do I map the elements of one matrix to another?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Noah Huffman
le 20 Juil 2017
Modifié(e) : Stephen23
le 20 Juil 2017
I am trying to transform a matrix A to A' where the indices are transformed by:
- y' = x
- x' = 1024-y
I am currently using the code:
for x = 1:1024
for y = 1:1024
f{x,y} = b(1024-y,x);
end;
end
but am getting a "Subscript indices must either be real positive integers or logicals." error. Any suggestions on how to do this?
0 commentaires
Réponse acceptée
Stephen23
le 20 Juil 2017
Modifié(e) : Stephen23
le 20 Juil 2017
If b has 1024 rows then you will need:
1+1024-y
otherwise the lowest calculated index value will be zero (MATLAB indexing starts at one).
Better alternative: doing this in a loop is likely not very efficient, you should simply use indexing directly, e.g.:
fliplr(b.')
or
b(end:-1:1,:).'
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!