I am trying to model the below problem using Matlab-CVX:
Here, x, y and u are variables. My code is:
for i = 1: K
f = 10 * (y(1,i) - y_ref)^2 + (u(1,i))^2; disp(f); minimize(f) subject to x(1,i+1) == A * x(1,i) + B * u(1,i); y(1,i) == C * x(1,i); -1 <= u(1,i) <= 1; cvx_end
However, I am getting error that index exceeds matrix dimensions. I can’t see where it’s causing the problem. Any help is appreciated. Thanks.