extracting a range of values from a vector
    27 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    giuseppe insignito
 am 18 Nov. 2020
  
    
    
    
    
    Kommentiert: HabenG
      
 am 1 Dez. 2021
            I have an array indx = [ 1 7 4 8 11 6 3] and I need to extract from 1 (minimum) to 4 (maximum) of the actual value (Not the index!) of the elements of indx and put them into another array indx_w (wich results in this case = [1 3 4])
How to do it?
indx_w = ????
thanks!
0 Kommentare
Akzeptierte Antwort
  Ameer Hamza
      
      
 am 18 Nov. 2020
        
      Bearbeitet: Ameer Hamza
      
      
 am 18 Nov. 2020
  
      You can use logical indexing
indx = [ 1 7 4 8 11 6 3];
lb = 1;
ub = 4;
mask = (indx >= lb) & (indx <= ub);
indx_w = indx(mask)
If you also want the output to be sorted
indx_w = sort(indx_w)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


