Guest User

Untitled

a guest
Nov 10th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. X = [1 -1 2 -1;
  2. 1 -1 -1 1;
  3. 1 2 3 -1];
  4.  
  5. for i = 1:size(X, 2)
  6. column = X(:, i);
  7. idx = find(column > 0, 1);
  8. if idx == 1
  9. continue
  10. end
  11. if isempty(idx)
  12. X(:,i) = X(:,i)*0;
  13. continue
  14. end
  15. column(1:idx-1) = 0;
  16. column = circshift(column, -idx+1);
  17. X(:, i) = column;
  18. end
  19.  
  20. X
Advertisement
Add Comment
Please, Sign In to add comment