You can index the variables as you want
rot_mat1 = Variable(torch.zeros(3, 3), requires_grad=False)
rot_mat1[1, 1] = a.cos()
...

I’d initialize the matrix with all the fixed values (using a tensor), and I’d then assign the variable elements after the Variable was created.