26 views (last 30 days)

Show older comments

Shoaibur Rahman
on 22 Feb 2015

% xi eta

x =[1 2;...

3 4;...

4 5;...

6 7];

y = sum(x) % only sum of all elements along each column

y = cumsum(x) % cumulative sum along each column

Image Analyst
on 22 Feb 2015

Be more specific. Why can't you give us the series? Is it homework or something? If you don't get more specific then you'll just get more answers like dpb's (which is all your fault rather than dpb's because you were not specific enough to be able to answer your question).

What's wrong with using the sum() function, or even a brute force for loop()?

Image Analyst
on 22 Feb 2015

If you want to sum a 3D matrix "j" between certain rows and columns, do this

subArray = j(row1:row2, col1:col2, :);

theSum = sum(subArray(:));

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

Start Hunting!