I’m trying to do some trajectory optimization for a UAV, and it’s been successful when assuming that velocity would be constant. However now, I’m trying to set velocity as a variable, and hence make the problem more real-life like by also maximizing and minimizing its acceleration.

Here’s just a part of the code:

for T = [100 101 105 120 160];

cvx_begin quiet

variable x(T) complex

variable V(T) complex

variable a(T) complex

minimize(norm(x-xB))

V = (x(T)-x(T-1))/(T-(T-1)) %not really a condition

norm(x(1) - x0) <= V;

```
for t = 2:T
norm(x(t)-x(t-1)) <= V;
norm(x(t) - xH) <= V*(T-t);
a = (V(t)-V(t-1))/(t-(t-1));
cvx_end
```

Later, I want to maximize and minimize the acceleration at specific position ranges, however, CVX says this (below) once I introduce “a” as the derivative of V

**(Index exceeds array bounds.)**

I would really appreciate any help