I have a vector for example
a = [0 1 0 3]
I want to turn a into b which equals b = [1 3].
b = [1 3]
How do I perform this in gen
You could use sparse(a), which would return
(1,2) 1
(1,4) 3
This allows you to keep the information about where your non-zero entries used to be.