Dear all,
I need to do a loop as following:
#Consider a matrix:
M <- matrix(1, nrow=10, ncol=20)
#Matrices to store the looping results
M1 <- matrix(0, nrow=10, ncol=400)
h <- c(1:20/1000)
#loop
for (j in h){
M1 <- M/(2*j)
}
But this means that the first 20 columns of matrix M1 (that is, columns 1:20)
should show the results of M/(2*0.001). Then, the following 20 columns of M1
(that is, columns 21:40) should show the results of M/(2*0.002) and so on until
columns 381:400 that would show the results of M/(2*0.02).
What should I include in the loop above in order to have this result?
Thanks a lot!
Julia
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.