"payam " <payamvahdati@yahoo.com> wrote in message <kavbd0$ji8$1@newscl01ah.mathworks.com>...
> Hello all,
> I put my code here so you can understand better what i am looking for. This is my code :
>
> Lambda= 0.785;
> k= 2*pi/Lambda;
> S = 40;
> a= 0.3;
> l = 10;
> theta0= atan (S/l);
> n= (S/a) ;
> s= theta/n ;
> I0 = 100;
>
> for i=1:4*n
> for j=1:n
> I(i,j) = I0 *(sin((k*a/2)*sin(theta0(ji)*0.58)))/(k*a/2)*sin(theta0(ji)*0.58) ;
>
> end
> end
>
> I want at the end to have data that contains : [ I(1,:), I(2,:), I(3,:), ..... , I(4n,:) ]
> it means I want 4n numbers that are the sum up of all the js for each individual i.
% I don't have MATLAB installed on this computer,
% but one of:
doc sum
doc cumsum
% should help you and get you started.
% BTW, there are many improvements you can make to the above code.
% For one, I suggest preallocating I. Something like:
I = zeros(size(4*n,n))
% before the for loop.
