hi: below almost gets you there except for the endpoints. see filter for
more information.
d=0.5
L=20
x=seq(20, by=1, length.out=20)
temp <- as.numeric(filter(x,filter=c(d,(1-2*d),d),sides=2))
print(temp)
On Sun, Nov 9, 2008 at 10:57 PM, stephen sefick wrote:
#Is there a way to vectorize th
#Is there a way to vectorize the for loop
#maybe a fancy indexing trick?
#thanks
d=0.5
L=20
x=seq(20, by=1, length.out=20)
reflecting <- function(pre, d, L){
r=L-1
x=rep(0, L)
for(j in 2:r){
x[j]=((1-(2*d))*pre[j])+(d*pre[(j+1)])+(d*pre[(j-1)])
}
x[1
2 matches
Mail list logo