diff options
Diffstat (limited to 'templates/LQR.m')
-rw-r--r-- | templates/LQR.m | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/templates/LQR.m b/templates/LQR.m index c05237d..d23e64a 100644 --- a/templates/LQR.m +++ b/templates/LQR.m @@ -14,20 +14,14 @@ classdef LQR methods %constructor function obj = LQR(Q,R,params) - % YOUR CODE HERE - % obj.K = ... (save feedback matrix for use in eval function) A = params.model.A; B = params.model.B; - % [X, L, G] = dare(A,B,Q,R); - [K,S,e] = dlqr(A,B,Q,R) - % obj.K = -inv(B'*P_inf*B+R)*B'*P_inf*A; - obj.K = -K; + [K,~,~] = dlqr(A,B,Q,R); + obj.K = K; end function [u, ctrl_info] = eval(obj,x) - % YOUR CODE HERE - % u = ... - u = obj.K*x; + u = -obj.K * x; ctrl_info = struct('ctrl_feas',true); end end |