summaryrefslogtreecommitdiffstats
path: root/templates/traj_cost.m
diff options
context:
space:
mode:
authorYuan Xu <yuanxu@student.ethz.ch>2023-05-07 21:10:45 +0200
committerYuan Xu <yuanxu@student.ethz.ch>2023-05-07 21:10:45 +0200
commitce14ae31fcb13362ff341e54ace5dccc4f94c095 (patch)
treeb082d1e3201b40a73e9dbb4f124708e752941468 /templates/traj_cost.m
parentADD: progress log (diff)
downloadmpc_pe-ce14ae31fcb13362ff341e54ace5dccc4f94c095.tar.gz
mpc_pe-ce14ae31fcb13362ff341e54ace5dccc4f94c095.zip
update 15,16 and modify generate_constraints.m
Diffstat (limited to '')
-rw-r--r--templates/traj_cost.m6
1 files changed, 6 insertions, 0 deletions
diff --git a/templates/traj_cost.m b/templates/traj_cost.m
index 7e0b443..57566c9 100644
--- a/templates/traj_cost.m
+++ b/templates/traj_cost.m
@@ -8,4 +8,10 @@
function J_Nt = traj_cost(Xt,Ut,Q,R)
% YOUR CODE HERE
+ J_Nt=0;
+ for i=1:length(Xt(1,:))-1
+ a= Xt(:,i)'*Q*Xt(:,i);
+ b= Ut(:,i)'*R*Ut(:,i);
+ J_Nt=J_Nt+a+b;
+ end
end \ No newline at end of file