You input phi_i in function W as follow
ii = 1:m;
m = m;
Now you feed input W function a value (m), suppose 3
the function phi_i gets following
phi_i(1:3,3)
So that's why you will get value when executing W(3)
On the other hand
This will not give you output until you provide ii value in your workspace
W = @(m) ( r + s*sum(sin(gama + pi/2 - phi_i(ii, m))) );
