MATLAB: How to make all negative values in a matrix 0

columnnegative values

for i= 1: size(A,1)
if A (i, 2) <= 0
DataNew(i,2) = 0
This is what I have now, but there are still negative values in my DataNew matrix

Best Answer

%% Set all negative elements to 0
A(A<0) = 0;
%% Set second column elements to 0
col = 2;
a(a(:,col)<0,col) = 0;