# Cvx expression issue

Can I define variable in the form of three-dimension matrix like
variable R_User_o(RRH_Num * RRH_Ant,RRH_Num * RRH_Ant,UE_Num)
Then in the constraints use expression like
sum(R_User_o,3)
R_User_o(:,:,ue) == hermitian_semidefinite(RRH_Num * RRH_Ant)
These expression matlab shows warning like variable not been defined before
Thank you very much

The code extracts you show look almost (see next sentence), o.k., so you would have to show your actual code and error message for an assessment of what’s wrong. You should not have an `== hermitian_semidefinite` constraint without having declared the matrix being so constrained to be hermitian. That can be accomplished by including `hermitian` at the end of the 3D variable declaration statement. But as long as you’re going to do that, it’s easier to just declare it `hermitian semidefinite` in the variable statement

`variable R_User_o(RRH_Num*RRH_Ant,RRH_Num*RRH_Ant,UE_Num) hermitian semidefinite`

Then there is no need for `== hermitian_semidefinite`
All the 2D (first 2 dimensions) slices get constrained to be hermitian semidefinite.

Thank you very much for your suggestions, actually it is about I am not so certian that if I can define 3D variable in cvx because Matlab report warning shows that the 3D variable has not been defined in constraints(the wavy underlines), while I do declare the variable. This situation really confuses me.

I can’t say more unless you show your actual code and error message, not just extracts and your “summary” of the error message.

Thank you for your reply, There is no error in the code gramatically, I just want to make sure that cvx can accept 3D variables. 3D operations I used in for loop like slicing indexing, sumation along the third axis are interpreted in cvx exactly the same as Matlab does.