mapping between two different matrices
    6 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Supriya Gain
 le 24 Avr 2023
  
    
    
    
    
    Réponse apportée : Kevin Holly
    
 le 24 Avr 2023
            I have a matrix a=[1 2;3 4;5 6] and i have another matrix b=[1 2 3;1 2 3;1 2 3;1 2 3;1 2 3]. Now I want to map between two matrices in such a way that the first row of matrix 'a' is indicating the first column of matrix 'b'. Like, if I type [1 2], it should show [1;1;1;1;1]. If I type [3  4] it should show [2;2;2;2;2].
How to do that? 
0 commentaires
Réponse acceptée
  Fangjun Jiang
      
      
 le 24 Avr 2023
        a=[1 2;3 4;5 6];
b=[1 2 3;1 2 3;1 2 3;1 2 3;1 2 3];
c=[1 2];
[~,index]=ismember(c,a,'rows');
b(:,index)
0 commentaires
Plus de réponses (2)
  Kevin Holly
    
 le 24 Avr 2023
        a=[1 2;3 4;5 6]
b=[1 2 3;1 2 3;1 2 3;1 2 3;1 2 3]
index = 3;
output = yourmap(a,b,index)
index = 6;
output = yourmap(a,b,index)
index = [1 2];
output = yourmap(a,b,index)
function output = yourmap(a,b,index)
[row,column] = find(a==index);
output = b(:,row);
end
0 commentaires
Voir également
Catégories
				En savoir plus sur Matrix Indexing 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!



