Hello, I am trying to vectorize the following simple code
if trueA=[-1;3;0;-4];B=zeros(size(A));for i=1:4 if A(i)<0 B(i)=-(A(i)); elseif A(i)==0 B(i)=1; else B(i)=A(i); end B=B(:);end endPlease, how do I write the above code in such a way that there is no for loop, and still it works?
Best Answer