How to calculate arithmetic series?
51 views (last 30 days)
David Young on 21 Nov 2011
Does your first example look like this:
and your second example look like this:
where I'm using SUM to stand for a capital sigma symbol?
If so, you would evaluate them in MATLAB like this:
n = 100; % set n to whatever value you need
i_vector = 1:n;
s1 = sum(i_vector);
s2 = sum(i_vector.^2);
To understand these examples, it's essential to look up the colon ( : ) operator in the introductory documentation or your textbook, as it's at the core of how this kind of operation is usually done. Also look at the documentation for the sum function, and for the .^ operator.