How can I extract exact values from a single column of a matrix?
    6 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Sam Hurrell
 am 5 Jul. 2021
  
    
    
    
    
    Beantwortet: Star Strider
      
      
 am 5 Jul. 2021
            The matrix in question has x, y, z coordinates in its first 3 columns respectively. I tried using a for-loop to go through the matrix and if it came across a row where x=0.025 then it would copy the entire row to a second matrix in it's 'f' row then f=f+1. The second matrix was premade with zeros and is the correct size, however it keeps resulting in no change to it.
0 Kommentare
Akzeptierte Antwort
  Star Strider
      
      
 am 5 Jul. 2021
        Try something like this — 
M = randi(50, 50, 3)/1000                           % Original Matrix
Lv = M(:,1) == 0.025                                % Logical Vector 'Mask'
nrtrue = nnz(Lv)                                    % Number Of Occurrences (Optional)
N = M(Lv,:)                                         % New Matrix
Make appropriate changes to get the result you want.  
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Creating and Concatenating Matrices 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!