If-else constraints in CVX

t=24;
for i=10:t-4
if ((h_min<=H_t(i)) && (H_t(i)<=h_max))
H_t(i)=(h_max-H_t(i))^2;
else
H_t(i)=0;
end
end

I have this code in matlab inside CVX solver. When I run this script, DCP error appears: constraints may not appear in if/then statements.

Help me to overcome this challenge.

Please read the FAQ; and the chapter in the documentation on the DCP ruleset; your model is not convex.

I appreciate your quick reply