Function 'fmincon' not supported for code generation
이전 댓글 표시
Hello,
im currently trying to implement nonlinear MPC in MATLAB/Simulink using the MATLAB function block.
function u_mpc = MPC(x, u_mpc, u_0, A_ineq, b_ineq, Q_mpc, R_mpc)
costfunc = @(x,u) (x)'*Q_mpc*(x) + (u_mpc)'*R_mpc*(u_mpc);
u_mpc = fmincon(costfunc, u_0, A_ineq, b_ineq);
end
The state x is provided by a plant model, the costfunction is a simple quadratic cost with weight matrices, the matrices are taken from the workspace.
Running the Simulink model results in the error: Function 'fmincon' not supported for code generation.
I'm using the 2018b version normally, tried using 2021a but got the same error.
Is there a mistake in the code or is it simply not possible to use fmincon inside a MATLAB function block?
Thanks in advance for any help.
댓글 수: 2
Walter Roberson
2021년 5월 8일
편집: Walter Roberson
2021년 5월 11일
You need to provide options
Anuschan Albrecht
2021년 5월 8일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!