The following cvx variable(s) have been cleared or overwritten: qn vn This is often an indication that an equality constraint was written with one equals '=' instead of two '=='. The model must be rewritten before cvx can proceed

As described in the title, i need to declare velocity and coordinate in the cvx problem.
I put the funtion between velocity and coordinate in ‘subject to’ and the whole cvx problem didn’t works.
The error is as follows:
The following cvx variable(s) have been cleared or overwritten:
qn vn
This is often an indication that an equality constraint was
written with one equals ‘=’ instead of two ‘==’. The model
must be rewritten before cvx can proceed.

I wonder whether the equation assignment formula can’t be placed in the constraint.

Please show your program if the error message doesn’t provide a good enough hint as to how to fix it. Expression assignments, which use = are different than equality constraints, which use == . There is a lot of flexibility (but not unlimited) as to where such such statements are placed

Thank you for your reply.
My program are as follows:

detaT=0.5; % interval of time
T=60; % total time
NNN=T/detaT; %number of intervals
Vmax=50; %the max velocity of UAV
Vmin=14; %the min velocity of UAV

cvx_begin
expression B;
variable qn(2,NNN);
variable vn(2,NNN);
variable an(2,NNN);

for j=1:NNN
ee(j)=pow_pos(norm(vn(:,j)),3);
ee2(j)=sum_square_abs(an(:,j))/g^(2);
B=B+ee(j)+ee2(j);
end

maximize(B);
subject to
for t=1:NNN
if(t==1)
(qn(1,1)-x0)^(2)+(qn(2,1)-y0)^(2)<=(VmaxdetaT)^(2);
qn(:,t)=[x0;y0];
vn(:,t)=[0;30];
else
(qn(1,t)-qn(1,t-1))^(2)+(qn(2,t)-qn(2,t-1))^(2)<=(Vmax
detaT)^(2);
qn(:,t)=qn(:,t-1)+vn(:,t-1)detaT+0.5an(:,t-1)*power(detaT,2);
vn(:,t)=vn(:,t-1)+an(:,t-1)*detaT;
end
end
cvx_end

When the program run to cvx_end, it shows the error. Actually, i used ‘expression’ instead of ‘variable’ to allow the coordinate and velocity be assigned. Then the program ran out without error but with a NaN or -Inf results.

In my question, i need obtain a optimal location and velocity. In my opinion, location and velocity can’t be declared as expression, they must be variables.

Hope you can answer my doubts.

Sorry, I lost ‘-’ in front of B.
It should be
maximize(-B);

I think the error message provided a good hint as to your error.

The 4 statements you have which begin with
qn(:,t)=
or
vn(:,t)=
should use
==
i.e., be equality constraints.

I don’t know whether the rest of your program is correct, but you need to at least fix this,