MATLAB: Round number closest to 0 in array

rounding zero

I have an array with numbers which are all really small (-9e-07 upto 2e+06). I want to round the values in each column of a 4D array,F, which are the closest to zero, to zero.

Best Answer

[~,idx]=min(abs(a))
a(idx)=0