MATLAB: Writing several sums of terms in matlab

series summation

I wish to write (6x+12x+18x+24x+30x+...+300x)+(6xexp(-x)+12xexp(-x)+18xexp(-x)+...+300xexp(-x) in matlab script.

Best Answer

I would write it as one anonymous function:
F = @(x) sum(sum([x exp(-x)]' * [6:6:300],1),2);
Y = F(1)
Y =
10.4643e+003