I tried to delete this post since it is similar to my other recent post Creating a matrix of variables in optim but I could not. I am having trouble translating the variables R and Q. In JuMP I have currently:

```
@variable(m, Rdiag[i=1:N]) # first create the variables that will fill the array
R = flipdim(Matrix(Diagonal(Rdiag)),2) # create the array with those variables along its diagonal
@variable(m, Qdiag[i=1:N])
Q = Diagonal(Qdiag)
```

And I will be optimizing a further expression which takes input variables Q and R, so basically I want optim to vary the diagonal or flipped diagonal components of Q and R respectively, thus varying Q and R, thus optimizing my function e_c:

```
T=kron(Q,Diagonal(ones(2)))+kron(Diagonal(ones(2)),conj(Q))+kron(R,conj(R))
Exp1.==e.^(T)
One=trace((Exp1)*(kron(C(Q,R),C(conj(Q),conj(R)))))
Two=c*trace((Exp1)*(kron(C(R,R),C(conj(R),conj(R)))))
e_c=append!(One,Two)
res = optimize(e_c,
method = GradientDescent())
```