Acquiring related Matrix Members
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I have a n by m matrix A and 1 by n array B. Assume
 A = rand(3,5)
 B = [3;5;2]
How can I get 1st rows 3rd element, 2nd rows 5th element and 3rd rows 2. element of A matrix w/o for loop?
Each rows related element is the member of B array as you can see?
0 comentarios
Respuesta aceptada
Más respuestas (1)
  Andrei Bobrov
      
      
 el 7 de Ag. de 2012
        
      Editada: Andrei Bobrov
      
      
 el 7 de Ag. de 2012
  
      out = A(sub2ind(size(A),(1:numel(B))',B(:)));
0 comentarios
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


