hello all.I have a big problem. i have a 5*3 matrix.I want to eliminate rows that the third column related to it, is less than 3.how can I do this? I have no idea. thanks a lot
    4 views (last 30 days)
  
       Show older comments
    
    fariba amini
 on 17 Jul 2016
  
    
    
    
    
    Commented: fariba amini
 on 17 Jul 2016
            for example:a=[1 2 3;4 3 2;1 4 6;8 3 0;2 4 1]; and the answer is: [1 2 3;1 4 6]
0 Comments
Accepted Answer
  Image Analyst
      
      
 on 17 Jul 2016
        Try this:
a=[1 2 3;4 3 2;1 4 6;8 3 0;2 4 1]; 
% and the answer is: [1 2 3;1 4 6]
% Find rows where the third column is less than 3.
rowsToDelete = a(:,3) < 3;
% Delete those rows.
a(rowsToDelete, :) = []
3 Comments
  Image Analyst
      
      
 on 17 Jul 2016
				Yes. Let's say that rowsToDelete had 3 rows in it, but that you wanted to delete only the first and last one, and the second one you wanted to keep (not delete). So just delete the second element from rowsToDelete:
rowsToDelete(2) = []; % Don't delete row in second location.
More Answers (0)
See Also
Categories
				Find more on Loops and Conditional Statements in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
