How to increase or decrease granularity of a matrix?
Afficher commentaires plus anciens
I want to increase or decrease the granularity of a matrix by a scalar factor, which would look like this:
Increasing Granularity
Increasing the granularity of a matrix replicates elements to scale the size of the matrix up by an integer factor.
A = [1 2
3 4]
B = increase(A, 2)
B = [1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4]
Decreasing Granularity
Decreasing the granularity of a matrix averages together elements to scale the size of the matrix down by an integer factor.
C = [1 2 3 4
5 6 7 8
4 1 8 3
6 7 2 5]
D = decrease(C, 2)
D = [(1+2+5+6)/4 (3+4+7+8)/4
(4+1+6+7)/4 (8+3+2+5)/4]
D = [3.5 5.5
4.5 4.5]
Is there a way to accomplish these workflows in MATLAB?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Interpolation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!