Octave is one of the popular and open-source language used in Machine Learning. In this post, I'll discuss sum function, which is commonly used especially if you are following up the Machine Learning course by Andrew Ng on Coursera. Let's start by defining a 2x3 Matrix >> A = [1, 2, 3; 4, 5, 6] A = 1 2 3 4 5 6 We can access a single element from matrix by specifying row,column index. For example, if we want to access the second element from first row, it would be >> A(1,2) ans = 2 If we have to access all the elements from first column, syntax would be : >> A(:,1) ans = 1 4 With colon (:), we are saying to access all the rows but only first column. We can also access multiple columns as >> A(:,[1,3]) ans = 1 3 4 6 Same syntax can be extended to access all the elements from a given row, the example below will access all the elements from second row >> A(2,:) ans = 4 5 6 What if we want to