MATLAB: Replace duplicate value by 0 in matrix or vector matlab functionSystemTest How do we replace duplicate value by 0 in matrix or vector ? for example Input: b = 1 2 1 3 Output:: b= 1 2 0 3 Thanks Best Answer b = [1 2 1 3]; [a,c] = unique(b,'first'); out = zeros(size(b)); out(c) = a; Related SolutionsMATLAB: Sort cell array columns by two dimensions array = {'A' 'A' 'B' 'B' 'B' 'C' 'C' 1 0.1 1 0.1 0.5 1 0.1 2 3 2 4 5 2 3}array=sortrows(array',[1,2])' MATLAB: How to detect which rows are left in the matrix when the unique function is used to eliminate the repeated rows [C,ia,ic] = unique(A,'rows') Related QuestionHow to pull out rows with a unique value in a specified columnHow to sort matrix according to another matrix in matlabFind unique in matrix of x,y coordinatesHow does a matrix sort based on another matrixIdentify duplicate rows in a matrixStoring only part of the output of a function with multiple outputs
Best Answer