MATLAB: Subtract row from previous row row I have a column of data (n long) and I want to subtract each row from the previous. So x = 1 2 6 1 etc and I want to subtract row 2 from row 1, then row 3 from row 2 … etc. Ans = -1 -4 5 etc. Best Answer x(1:end-1)-x(2:end) Related SolutionsMATLAB: How to eliminate certain columns from a matrix Let A be matrix A(:,1:2:end) = [] % remove odd columnsA(:,3) = [] % remove third columnidx = [1 2 5 7] ;A(:,idx) = [] % remove columns specified in idx MATLAB: Subtract numbers in the row diff(x) Related QuestionI want to create a matrix where each column is obtained by subtracting 1 from the previous column.Subtracting every other rowSubtract rows in matrix using loopAveraging rows with rows previous
Best Answer