MATLAB: How to find and substract only these values from a dataset which are bigger than a threshold

dataset threshold

Hey people. I am quite new with matlab. I have a big dataset consisting of three columns (x,y,z). I would like to find x-values which are bigger than a threshold. these values i would like to substract by 360. I was thinking of a if condition sth like:
if x > 180
xnew = x - 360;
else
xnew = x;
end
This is obviously wrong. Does somebody have a advice? Thanks a lot in advance! Cheers P

Best Answer

xnew = mod(x+180,360)-180