matrix column element limiting
    3 views (last 30 days)
  
       Show older comments
    
hi,
I have a matrix say 200*30. I need to limit the elements of 29th and 30th columns with different constraints. how can I do that?
thanks,
0 Comments
Accepted Answer
  Azzi Abdelmalek
      
      
 on 8 Jul 2015
        Example
A=rand(200,30)
idx=A(:,29)>0.5 & A(:,30)<0.7
out=A(idx,:)
4 Comments
  Stephen23
      
      
 on 8 Jul 2015
				
      Edited: Stephen23
      
      
 on 8 Jul 2015
  
			Azzi Abdelmalek's solution is much more optimized than using a loop. This is how MATLAB works best, using basic code vectorization and indexing.
More Answers (0)
See Also
Categories
				Find more on Matrix Indexing 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!

