I am using a Markov model with matrices programmed in R to solve a health economic problem.

I have a matrix that I would like to exponentiate 200 times. The values within the matrix change over time. For example the value on position x12 is in the first matrix 0.1 in the second 0.2 and in the third 0.3. I do not want to write down 200 matrices but rather one and exponentiate it by 200. For x12: could I use a vector with 200 values and the matrix would use that vector?

For constant values, it is no problem:

```
############### Imatinib Base-line Strategy ##########################
trans_matrix_dasa_no2nd <- matrix (,nrow=3,ncol=3)

trans_matrix_dasa_no2nd[1,] <- c(0.9,0.05,0.05)
trans_matrix_dasa_no2nd[2,] <- c(0,0.8,0.2)
trans_matrix_dasa_no2nd[3,] <- c(0,0,1)

cycle_patient_distribution_dasa_no2nd <- matrix (,nrow=2,ncol=3)

for (i in 1:2){cycle_patient_distribution_dasa_no2nd[i,] <- 
           initial_patient_distribtion%*%(trans_matrix_dasa_no2nd%^%i)}

cycle_patient_distribution_dasa_no2nd
     [,1] [,2] [,3]
[1,]  900   50   50
[2,]  810   85  105

```

But if I use the vector, it is not working any more:

```
############### Imatinib Base-line Strategy ##########################
aaa <- c(0.9,0.5)
bbb <- c(0.05, 0.4)
ccc <- c(0.05, 0.1)

trans_matrix_dasa_no2nd <- matrix (,nrow=3,ncol=3)

trans_matrix_dasa_no2nd[1,] <- c(aaa,bbb,ccc)
Error in trans_matrix_dasa_no2nd[1, ] <- c(aaa, bbb, ccc) : 
  number of items to replace is not a multiple of replacement length
trans_matrix_dasa_no2nd[2,] <- c(0,0.8,0.2)
trans_matrix_dasa_no2nd[3,] <- c(0,0,1)

cycle_patient_distribution_dasa_no2nd <- matrix (,nrow=2,ncol=3)

for (i in 1:2){cycle_patient_distribution_dasa_no2nd[i,] <- 
         initial_patient_distribtion%*%(trans_matrix_dasa_no2nd%^%i)}

cycle_patient_distribution_dasa_no2nd
     [,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]   NA   NA   NA

```

if I introduce i into the matrix, the results are not correct:

```
############### Imatinib Base-line Strategy ##########################
aaa <- c(0.9,0.5)
bbb <- c(0.05, 0.4)
ccc <- c(0.05, 0.1)

trans_matrix_dasa_no2nd <- matrix (,nrow=3,ncol=3)

trans_matrix_dasa_no2nd[1,] <- c(aaa[i],bbb[i],ccc[i])
trans_matrix_dasa_no2nd[2,] <- c(0,0.8,0.2)
trans_matrix_dasa_no2nd[3,] <- c(0,0,1)

cycle_patient_distribution_dasa_no2nd <- matrix (,nrow=2,ncol=3)

for (i in 1:2){cycle_patient_distribution_dasa_no2nd[i,] <- 
      initial_patient_distribtion%*%(trans_matrix_dasa_no2nd%^%i)}

cycle_patient_distribution_dasa_no2nd
     [,1] [,2] [,3]
[1,]  500  400  100
[2,]  250  520  230

```

How could I solve that problem?
Many thanks!