MATLAB: How to write this summation in matlab form ∑_(u=1)^(su-2)

equationMATLAB

in this summation..the lower limit is u=1 and the upper limit is su-2. how can i write this summation limits in matlab form?

Best Answer

If you have the symbolic toolbox, use symsum()
syms u
symsum(YourExpression, u, 1, su-2)
If you do not have the symbolic toolbox, then either use a for loop that accumulates the results, or else use an expression that calculates each term independently and then sum() them together. You could also consider using arrayfun()
arrayfun(@(u) YourExpression, 1:su-2)
Related Question