Question: I am working with Matlab and i have the following problem. I have a matrix let's say `A`

```
A =

 1     0     0     1     0     0
 1     0     1     0     0     0

```

I want to be able to delete the columns that have only zeros but only after the last column with at least one 1 i.e column 5 and column 6 but not column 2. I cannot just do `A(:,5)=[]` because in my problem i don't know which columns have zeroes and they are in the end.

Answer: 
Or, with fewer lines

```
b = A(:,1:find(any(A),1,'last'))

```
try this

```
zerocols=sum(A,1)
b=A(:,1:find(zerocols~=0,1,'last'))

```