I want to extract values from second column of the matrix which correspond to the range 6 to 7 of the first column. How to do it?
    8 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Abhishek Chakraborty
 el 8 de Mzo. de 2020
  
    
    
    
    
    Comentada: Abhishek Chakraborty
 el 8 de Mzo. de 2020
            I have a 2 column matrix. Each column contains around 4 million elements (numbers). I have sorted the matrix with respect to increasing order of the first column. I want to extract the values from the second column which are corresponding to values between 6 and 7 of the first column. How to do it ? 
0 comentarios
Respuesta aceptada
  Turlough Hughes
      
 el 8 de Mzo. de 2020
        Let's say your matrix is called M, then you can extract rows from column 2 corresponding to those in column 1 which are between 6 and 7 as follows:
result = M(M(:,1)<=7 & M(:,1)>=6,2);
You can also see the output from both columns to confirm that it is correct:
M(M(:,1)<=7 & M(:,1)>=6,:)
Más respuestas (0)
Ver también
Categorías
				Más información sobre Shifting and Sorting 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!

