I presume you actually have a more complex model. If it is just two
securities which cannot be selected at the same time, simply solve two
optimization problems where each one of them is set to 0.
In the
general case, your nonlinear nonconvex formulation is not a good
strategy (if you want to aim for a globally optimal solution). Much
likely much better to pose it as a mixed-integer quadratic program, along the lines of
select = binvar(2,1);
Sharpe = [..., z(16) <= select(1), z(18) <= select(2), sum(select) == 1]
Likewise, YALMIP automatically will create an integer model if you simply use complements
Sharpe = [..., complements(z(16)>=0, z(18)>=0]
You might have to add an explcicit upper bound on z (z<=1) for YALMIP to derive a nice big-M model.