I have to put 54 matrices in a list of vector called A. I want the first 25 matrices in this list to be zero matrices except the (i,j)th element of the matrix, which should be equal to one. All my matrices are 5x5. I am using a for loop, but I dont understand how to create the first 25 matrices.
Now I am trying to make 16 matrices of 0 with (i:(i-1),j:(j-1))th element = 1, so that there is a square of 1s of size 2 by 2. For this I have used the following code, but I want to make sure that 'i' is greater that or equal to 2. how can I do this?
t<-26
for(i in 1:5){
for(j in 1:5){
A <- matrix(0, nrow = 5, ncol = 5)
A[i:(i-1), j:(j-1)] <- 1
M[[l]] <- A
t <- t+1
}
}
A