I have a binary matrix, say:

```
matrix=double(rand(100,100)>0.7);

```

I want to find all "diagonal lines" of 1's (from bottom left to top right) of length 2 or more elements in this matrix and set all other 1's to 0, so that I get another matrix with only those diagonal lines.

I want to do the same for vertical lines.

Is there a simple way to do this?