From e29fa3f2c56286eaaccb6fbe54029037f2a02d5b Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 2 May 2023 13:27:31 +0200 Subject: ADD: Tasks 1-9 --- templates/LQR.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'templates/LQR.m') diff --git a/templates/LQR.m b/templates/LQR.m index 2a79da9..76d95c6 100644 --- a/templates/LQR.m +++ b/templates/LQR.m @@ -15,13 +15,16 @@ classdef LQR %constructor function obj = LQR(Q,R,params) % YOUR CODE HERE - % obj.K = ... (save feedback matrix for use in eval function) + E = np.zeros(params.model.nx); + S = np.zeros(params.model.nx); + Pinf = idare(params.model.A, params.model.B, Q, R, S, E, 'noscaling') + obj.K = -inv(R + B' * Pinf * B) * B' * Pinf * A; end function [u, ctrl_info] = eval(obj,x) % YOUR CODE HERE - % u = ... + u = obj.K * x; ctrl_info = struct('ctrl_feas',true); end end -end \ No newline at end of file +end -- cgit v1.2.1