Hi, I am trying to clean matrix A (which is a 1064 x 4 matrix) while relying in the cleaning process on Matrices B and C that have the same size as A (Mat file attached). I developed a loop to clean A but I feel that a loop is unnecessary and that I can do it without relying on loops. Could the cleaning process be done much more efficiently? Your help is appreciated.
for i=1:size(A,1)
for j=1:size(A,2)
if A(i,j)<1 && A(i,j)>0
A (i,j)=B(i,j);
end
if A(i,j)<C(i,j)
A (i,j)=nan;
end
if B(i,j)>100
A (i,j)=B(i,j);
elseif B(i,j)<0
A(i,j)=-999;
end
if C(i,j)==0
A(i,j)=0;
end
end
end
1 Comment
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/712828-getting-rid-of-loops#comment_1254238
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/712828-getting-rid-of-loops#comment_1254238
Sign in to comment.