Skip to content
Prev 312514 / 398506 Next

loop function and integrate?

On 30-11-2012, at 19:34, Berend Hasselman wrote:

            
There is no need to define the function H in the j loop.
You could do this:

H = function(x,A) {sin(x + A)}

for(j in 1:ia) {
     aj <- a[j]
     for(i in 1:ib) {
               int =  integrate(H, lower = 0, upper = x[i], A=aj)
               int1[i] = (1 + a[i])* int$value
               }
  ss[j] = sum(int1)
}

And if Rui is right  a[i] can be replaced by aj.

Berend