calc the total of the series in matlab

To calculate the total of a series in MATLAB you can use the sum function with appropriate arguments. Here is an example of calculating the sum of the series 1+2+3+...+10.

main.m
series = 1:10;
total = sum(series);
disp(total);
49 chars
4 lines

Output:

main.m
55
3 chars
2 lines

In this example, series is a vector that contains numbers 1 through 10, and sum(series) returns the sum of these numbers, which is 55.

related categories

gistlibby LogSnag