Removing zeros from vector


(marwa hisham zamzam) #1

i have a variable for example a=[1 2 4 0 5]
and i need to get another variable but after removing all zeros from vector a , for example b=[1 2 4 5]
i try (nonzero function) , find(a~=0) and many functions that remove zeros from a vector and they worked on the command window but when i write them in cvx , i think it see them if function so there is error
IS THERE ANY WAY TO REMOVE ZEROS FROM A VECTOR ??


(Mark L. Stone) #2

This has been categorized as non-convex.

However, perhaps there’s a way to handle this using CVX’s MIDCP capability, by using binary or integer variables, which do allow for modeling some non-convexities.


(marwa hisham zamzam) #3

Thanks Mark :slight_smile:
Do you know any link that will help me in this case


(Mark L. Stone) #4

I think you need to learn how to model “logic” type of things using binary or integer variables. I don’t have a specific reference to provide you.


(marwa hisham zamzam) #5

Okay thank you so much


Can i sort in cvx?