MATLAB: Subtract a row from a matrix matrix I have a matrix A = [ 1 2 3; 3 5 9; 1 8 0; 2 3 3 ] and the value of third row is stored in another matrix B = [1 8 0], how can i subtract B from A? i tried this A(B,:)=[] but not working. Best Answer >> A = [1,2,3;3,5,9;1,8,0;2,3,3];>> B = [1,8,0];>> [~,idx] = ismember(B,A,'rows');>> A(idx,:) = []A = 1 2 3 3 5 9 2 3 3 Related SolutionsMATLAB: Find indices of one array in another array. [~,idx]=setdiff(A,B,'rows');idx_rows=setdiff(1:size(A,1),idx) MATLAB: Deleting rows of matrix from the rows of other matrix with different dimension The simplest solution is to use ismember with its 'rows' option:idx = ismember(A(:,1:2),B,'rows');A(idx,:) = [] Related QuestionMatch row and columnList of maximum number in the matrixHow to substitute a row vector to a column of a matrixHow sort rows of matrix as per given indexWhat does M([1:1 2:3], [1:0 2:3]) mean
Best Answer