MATLAB: Indexing definite Summation notation

definite summationequationindexindexingMATLABsummation

I want to input the formula below into MATLAB to ultimately commpute 'W':
Can you please tell me if how can I correct my code or suggest a more concise one?
syms i
for i = 1:m
i = i + 1;
phi(i) = atan((d1+(i*d2/(m+1)))/(R/(3*m+3)));
W = symsum(sin(gama + ((pi/2) – (phi*i))), i, 1, m);
end

Best Answer

This numerically estimate the summation
d1 = 0.1; % example values
d2 = 0.5;
R = 1;
phi_i = @(ii, m) atan((d1 + (ii*d2)./(m+1))./(R/(3*(m+1))));
W = @(m, delta) sum(sin(delta + pi/2 - phi_i(1:m, m)));
W(10, 2)