MATLAB: Sum of range of matrix elements from starting and end point

matrix array

I have 90000*20 matrix i want to add 50 elements of 18th column successively. how can i do so please help.also could you please tell how to do sum of elements in the vector if the starting and end point is known.

Best Answer

Lets say the matrix data is variable name as "mat"
result=sum(mat(1:50,18))
"could you please tell how to do sum of elements in the vector if the starting and end point is known".
If 1-D vector, you can use sum directly
result=sum(mat(Start_index:End_index))
For 2 D case
data=mat(From rows:Till Rows number,From columns:Till Columns number)
result=sum(data(:))