How to use the "expression holder"?

In my CVX code, I want to construct one “expression holder” to hold the original declared variable, so as to invoke the original variable in the following code. For invoking the original variables more easily, the declared “expression holder” should satisfy the given dimensionality, which will result out that some elements in the declared “expression holder” will not be inserted with the original variable.

For example:
variable a(3);
expression c(4);
for i=1:3
c(i)=a(i);
end

a(4) has not been inserted with any original variable.

My question is: Is it OK that some elements in the declared “expression holder” will not be inserted with any original variable?

It’s o.k, as long as you don’t reference the unassigned elements. But if you do something like sum(c), where not all elements of c had been assigned prior to use, I’m not sure the behavior is defined or guaranteed. Nevertheless, on examples I tried, it seems that unassigned elements were skipped or assigned to 0.

Just don’t reference the unassigned elements, and everything should be fine.

Thank you!
I don’t reference the unassigned elemets.

Thanks again!! Your reply is quick and detailed.