MATLAB: How to replace elements using logical operations matrix manipulation Let A = [2 13 1; 2 5 16; 11 9 8] What I want to do is for element that are less than 6, replace the element with 0. How do I do this using for/if operation ? Thanks in advance. Best Answer Hi,try>> A(reshape(A < 6,[],1)) = 0 Related SolutionsMATLAB: How to do this operation A(1:length(A)-13) .* B MATLAB: Do a matrix,array This works:B = reshape(A', 1, []); Related QuestionBug in single/double operationsHow to replace the element in matrixReplacing elements in matrix with relational operationsReplace array valueLogical operations on logical matricesReplacing elements of a logical index vector
Best Answer