Henrique Andrade a écrit :
> <script>
> matrix R = zeros(12,1)
>
> loop i=6..12
>     R_$i = r[$i,1] + r[$i-1,2]+ r[$i-2,3]+ r[$i-3,4]+ r[$i-4,5]+ r[$i-5,6]
>     R[i] = R_$i
> end loop
> </script>
>
Hi Henrique,
Well, what do you think about the following general form :

<script>
matrix R = zeros(dim1,dim2)    # In your exemple dim1=12 and dim2=1
loop k = 1..dim2                     
    loop i = k+1..dim1
        loop j = 1..(k+1)
           R[i,k] = R[i,k] + r[1+i-j,j]
        endloop
    endloop
endloop
</script>

Artur

Reply via email to