Sum of specific elements in a column matrix

22 views (last 30 days)
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

Accepted Answer

madhan ravi
madhan ravi on 3 Dec 2018
Edited: madhan ravi on 3 Dec 2018
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

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!