You have at least two problems with your code. First, you need an explicit multiplication sign in these lines:
I(i) = I0*sin(k*(l/2 - z));
I(i) = I0*sin(k*(l/2 + z));
Second, your for loop is ill-defined, as probably does not do what you intend. You cannot specify a range of z values as you have here:
Instead, you need something more like
In this syntax, i is going to loop over the values of the vector z*l.