MATLAB: Detect same value value how do I detect on the elements of a (:, 1) there is the same value? a=[1 34; 2 33; 2 45; 3 32; 4 65; 4 99; 5 11; 1 33; 6 22] Best Answer u = unique(a(:,1));if length(u) ~= size(a,1) %there were duplicatesendIf you want to find out which are equal to which,bsxfun(@eq, a(:,1), a(:,1).'))and that will return a logical matrix in which for row r, column c is set if a(r) == a(c) Related SolutionsMATLAB: How to rearrange row of a matrix based on column value Try this:[~, sortOrder] = sort(v(:,4), 'descend')v2 = v(sortOrder,:) MATLAB: Option ‘stable’ of the command unique [a,idx]=unique(A)[ii,ii]=sort(idx);B=sum( bsxfun(@eq,A,a(ii)'))' Related QuestionIs there a command ( like “sort” for example ) arranges vector elements ascending ,max, descending (humped shap)Sort a matrix with indexingExtract Vector’s index from MatrixHow to sort (ascending or descending) a list of ID numbers based on the value in a corresponding vectorUsing bsxfun for non-numeric dataSelect unique couples from two vectors (?)
Best Answer