Sum of specific elements in a column matrix
13 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!