I want to set elements of the matrix based on some condition

I want to add constraints that if my elements matrix is less or equal to 0.01 then set it as 0 otherwise leave as it is.How to add such conditions.

That is called a semicontinuous variable, which can be handled by introducing a binary variable for each element of the matrix.

variable W(m,n)
variable B(m,n) binary
% Let U be matrix of upper bounds for corresponding elements of W
0.01*vec(B) <= vec(W) <= vec(U).*vec(B)

Thank you ,
I want to implement this constraint ,where below A_hat is 10 by 10 matrix

> A_hat == A_hat .* (abs(A_hat) >= 0.01)

Can you please confirm if below lines will work:

variable A_hat (m,n)
variable A_hat_b (m,n) binary
% Let U be matrix of upper bounds for corresponding elements of W
0.01*vec(A_hat_b ) <= vec(abs(A_hat )) <= vec(A_hat ).*vec(A_hat_b )

No, I answered the question you originally asked. If elements of A can be negative, then your adaptation of my solution is incorrect, because it doesn’t allow elements to be <= -0.01 .

You ought to be able to adapt the disjunctive inequalities treatment, for instance for x1, in https://optimization.mccormick.northwestern.edu/index.php/Disjunctive_inequalities to your situation. I will leave you to do so, so that you gain some facility.