Hi, I am a new user to CVX. I am trying to model the particular objective function
0.5 * (u(t)^2 + u(t + delta)^2 + ... + u(t + N * delta)^2. There are N variables.
I have written my code as
function acceleration = control(x0,v0,brake, acc, N, delta, minDist) cvx_begin variable x(N); variable v(N); variable u(N); whos minimize(1/2 * u' * u); subject to brake <= u; u <= acc; x >= minDist; x(1) == x0; v(1) == v0; for i = 1:N-1 x(i+1) == x(i) + delta * v(i) + 0.5 * delta^2 * u(i); v(i+1) == v(i) + delta * u(i); end cvx_end end
Upon running the code, I get
Error using norm First argument must be single or double. Error in computeControl>control (line 12) norm(brake <= u); But,
whos is giving the value as
norm and I get this
sqlp stop: dual problem is suspected of being infeasible
I couldn’t give the give the objective function as
minimize(0.5 * u.^2) since I got that the objective function is not scalar error. Any help would be greatly appreciated. Thanks.