MATLAB: Extracting rows from a matrix based on values in columns extract Following on from this question https://it.mathworks.com/matlabcentral/answers/283139-extracting-rows-from-a-matrix-based-on-values-in-columns What if I have more than 1 column? That is, I want A to be a 6-by-4 matrix for example, so to have C{1} = 4-by-3 matrix? Best Answer It's much easier to do this with the newer splitapply rather than the older accumarray:A = [[1;1;3;2;3;1], rand(6, 3)]C = splitapply(@(rows) {rows}, A(:, 2:end), A(:, 1)) Related SolutionsMATLAB: Find the repetition of matrix rows a = [1 2 3; 4 5 6;1 2 3; 3 2 4; 1 2 3; 3 2 1; 1 3 2] ;row2check = 1;repeated = 0 ;for i = 1 : size(a,1) repeated = repeated + prod(double([a(row2check,:)== a(i,:)])) ;endfprintf('\n Row number %i is reapeated %i times in matrix!\n\n',row2check,repeated); MATLAB: Column shuffling of a matrix A = imread('Untitled.png');m = size(A);out = zeros(m);m1 = round(m(2)/2);out(:,1:2:end,:) = A(:,1:m1,:);out(:,2:2:end,:) = A(:,end:-1:m1+1,:); Related QuestionExtracting repeated rows from table data based on conditionsAccumulate in multiple arrayFind the repetition of matrix rowsHow to calculate number of unique element in array
Best Answer