MATLAB: How can i add 2 row add row to row A=[-1,-1,0,0,0;0,0,0,-1,0;0,1,-1,0,-1;0,0,1,0,0;1,0,0,1,1] With that matrix how can i add row to row command (code) And in any kind of matrix? Best Answer A(FirstRow,:) + A(SecondRow,:)Or if you want to get fancier,sum(A([FirstRow, SecondRow],:)) Related SolutionsMATLAB: Adding rows with constraint b=cumsum(a); b(a==0)=0; MATLAB: How to place a cell array in another cell array using ‘find’ If I understood correctly:Ax = randi([0 1], 4, 960); %Demo data. No way I'm reformating your example to make it valid matlab syntax. [row, col] = find(A);blockidx = discretize(col, 1:60:size(A, 2));Bx = accumarray([row, blockidx], col, [], @(c) {sort(c).'})Note: I'm not working on the whole cell array here, just one of these 4x960 matrix as I've not understood what that had to do with the question. Possibly, you just want to above in a loop (or cellfun) operating over each element of the cell array. Related QuestionRowsHow to remove certain rows and columns in a matrixAdd all subsequent rows with selected rowLogical operation on column of a matrixChange binary string to decimalAdd rows to table
Best Answer