Dear cvx community,

I just began using cvx with Matlab and I encountered the following problem:

```
cvx_begin
variable Tlb(1,t);
expression T(n,t);
expression Tlsys(1,t);
expression b(n,1);
T(:,1) = T_init;
Tlsys(1) = Tsys_init;
for j=2:t
% compute vector b; b depends on T(:,j-1) and Tlb(j-1)
b(1) = -rho*Ac*dx*cp*T(1,j-1)/dt - (Tlb(j)*cp*mbnom+U*Ap*Tamb);
for i = 2:n-1
b(i) = -rho*Ac*dx*cp/dt*T(i,j-1) - U*Ap*Tamb;
end
b(n) = -rho*Ac*dx*cp/dt*T(n,j-1) -(U*Ap*Tamb+msys*cp*Tlsys(j));
T(:,j) = A\b;
Tlsys(j) = T(1,j) - Qsys(j-1)/msys/cp;
end
minimize sum((Tlb(2:end)-T(n,1:end-1)).*mbnom.*cp.*c(1:end-1)).*dt;
subject to
Tlb(1) == Tlbinit;
Tlb(2:length(tijd)) <=80;
(Tlb(2:length(tijd))-T(n,1:length(tijd)-1))*mbnom*cp <=Qbnom;
Tlsys(2:length(tijd)) >=20;
cvx_end
```

When I run the code I get the following error:

??? The following error occurred converting from cvx to double:

Error using ==> double

Conversion to double from cvx is not possible.

The errors come up in the lines where I calculate b(1), b(i) and b(n). When I replace these lines with b(1), b(i), b(n) = 5 (just a random constant for testing if this is the problem) I don’t get any errors and cvx minimizes the problem.

I specifically defined T, Tlsys and b to be cvx expressions, yet I get the error. What should I do?