The variables(such as PEGU,PB,SOC,E)are just vectors and they are related to time(Time is discrete,just like1,2,3,4…).So I want to know how I should show these variables in cvx.Do I should write these variables as PEGU(j),PB(j),SOC(j) and E(j) (j is discrete time) in constraints(subject to)?
Thank you.

The error message description is not as clear as perhaps it could be. This error message is not due to dimensional incompatibility (number of rows and columns), but does indicate a violation of CVX’s DCP rules. In particular, 2*R*C*E.*PB violates the rule prohibiting multiplication of two different CVX variables or expressions, in this case, E and PB.

If he constraint E-sqrt(E.^2-2*R*C*E.*PB)<=Imax*R*sqrt(2*C*E*nb) is convex, it will need to be reformulated. Have you proven it is convex?

Until you show otherwise, I will mark this problem as non-convex.