From 854247dee19c42b6f5b40a26bf0b6ea54f70293a Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Wed, 11 Sep 2024 22:20:31 +0200 Subject: [PATCH] [IMPROVE] build A_deq outside for loop --- control_act.m | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/control_act.m b/control_act.m index f655203..8f9ec21 100644 --- a/control_act.m +++ b/control_act.m @@ -118,23 +118,15 @@ function [u_corr, U_corr_history, q_pred] = ucorr(t, q, sim_data) % A will be at most PREDICTION_HORIZON * 2 * 2 (2: size of T_inv; 2: % accounting for T_inv and -T_inv) by PREDICTION_HORIZON (number of % vectors in u_corr times the number of elements [2] in each vector) - A_deq = []; b_deq = []; - - s_ = SATURATION - ones(2,1)*PREDICTION_SATURATION_TOLERANCE; for k=1:pred_hor T_inv = T_inv_pred(:,:,k); u_track = u_track_pred(:,:,k); - - % [T_inv; -T_inv] is a 4x2 matrix - %A_deq = blkdiag(A_deq, [T_inv; -T_inv]); - A_deq = blkdiag(A_deq, [eye(2); -eye(2)]); - - d = T_inv*u_track; b_deq = [b_deq; s_ - d; s_ + d]; end + A_deq = kron(eye(pred_hor), [eye(2); -eye(2)]); %A_deq %b_deq % unknowns