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 wish
command window:
ans =
42