Guest User

Untitled

a guest
Aug 10th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. how I can eliminate in a matrix all columns whose last two elements are equal? in Matlab
  2. A=[1 2 3 ; 4 5 6 ; 5 5 5]
  3.  
  4. A =
  5.  
  6. 1 2 3
  7. 4 5 6
  8. 5 5 5
  9.  
  10. A(:,A(end,:)==A(end-1,:))=[]
  11.  
  12. A =
  13.  
  14. 1 3
  15. 4 6
  16. 5 5
  17.  
  18. index = (A(:,end) == A(:,end-1) );
  19.  
  20. A(:,index) = [];
  21.  
  22. B = A( : , A(: , end-1) ~= A(: , end) )
Add Comment
Please, Sign In to add comment