quadratic term in the objective function

4 visualizaciones (últimos 30 días)
Zicheng Cai
Zicheng Cai el 1 de Oct. de 2019
Comentada: Zicheng Cai el 1 de Oct. de 2019
I was trying to use MATLAB to implement an MPC algorithm and have trouble describing the objective function.
Say I want to get a summation , where Q is a weight matrix.
I want to use a matrix X in . Each row represents the state of the system at a discrete time step and the dimension of the state is n.
I need a compact notation without indexing because I want to directly include it in a objective function in CVX.
Only thing I can come up with is to use trace(). It should work as the diagonal elements of ) are exactly what I want. But I am wondering if there is a better way to formulate it, as the methond I used computes some prudct that I won't use.
Thank you.

Respuesta aceptada

Matt J
Matt J el 1 de Oct. de 2019
Editada: Matt J el 1 de Oct. de 2019
sum(X.*(X*Q),2)
  1 comentario
Zicheng Cai
Zicheng Cai el 1 de Oct. de 2019
I want to get a scalar result with all entries summe up. sum(sum(X.*(X*Q),2) works. Thank you for the quick response.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by