This is an example of your use case on a 2-D matrix. The same is scalable for a 3-D matrix.
X = rand(5)
X =
0.7577 0.7060 0.8235 0.4387 0.4898
0.7431 0.0318 0.6948 0.3816 0.4456
0.3922 0.2769 0.3171 0.7655 0.6463
0.6555 0.0462 0.9502 0.7952 0.7094
0.1712 0.0971 0.0344 0.1869 0.7547
X(X<0.5) = 0;
X =
0.7577 0.7060 0.8235 0 0
0.7431 0 0.6948 0 0
0 0 0 0.7655 0.6463
0.6555 0 0.9502 0.7952 0.7094
0 0 0 0 0.7547