Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- X = [1 -1 2 -1;
- 1 -1 -1 1;
- 1 2 3 -1];
- for i = 1:size(X, 2)
- column = X(:, i);
- idx = find(column > 0, 1);
- if idx == 1
- continue
- end
- if isempty(idx)
- X(:,i) = X(:,i)*0;
- continue
- end
- column(1:idx-1) = 0;
- column = circshift(column, -idx+1);
- X(:, i) = column;
- end
- X
Advertisement
Add Comment
Please, Sign In to add comment