MATLAB: Sum of specific elements in a column matrix summation Say I have a column matrix [1;2;3;4;5;6;7;8;9]. I want to add the elements from row 3 to row 9. So the result will come as 42 Best Answer a=[1;2;3;4;5;6;7;8;9];sum(a(3:size(a,1))) % size(a,1) can be whichever element you wishcommand window:ans = 42 Related SolutionsMATLAB: Sum of array elements with specific condition >> fliplr(cumsum(fliplr(A)))ans = 9 8 8 7 6 6 5 5 4 4 4 3 2 1 MATLAB: How to sum specific matrix elements Try this:rowsToSum = A(:, 2) < 0;theSum = sum(A(rowsToSum, 1)); % Sum first column where second column is negative. Related QuestionExtract the Maximum Column elements of every RowSum of matrix elementsSum five elements before a specific numberHow to filter rows with respect to specific entrySumming specific pixel values
Best Answer