how can i apply 1 of k coding scheme on 2D MATRIX
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
GHUFRAN AHMAD KHAN
le 12 Sep 2018
Commenté : GHUFRAN AHMAD KHAN
le 12 Sep 2018
the order of matrix can be any number except 1.
3 commentaires
Réponse acceptée
Andrei Bobrov
le 12 Sep 2018
C = randi([1,3],2,4)
[m,n] = size(C);
k = max(C(:));
out = zeros(n,k,m);
[ii,kk] = ndgrid(1:m,1:n);
out(sub2ind([n,k,m],kk(:),C(:),ii(:))) = 1
5 commentaires
Andrei Bobrov
le 12 Sep 2018
use
C = A + 1;
[m,n] = size(C);
k = max(C(:));
out = zeros(n,k,m);
[ii,kk] = ndgrid(1:m,1:n);
out(sub2ind([n,k,m],kk(:),C(:),ii(:))) = 1;
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!