fmincon in MATLAB Function block (SIMULINK)
Ältere Kommentare anzeigen
Hello! I'd like to do MPC controller by using MATLAB. Could u help me with my problem? I try to use 'fmincon' in MATLAB Function block in simulink. There is my code in Function block in simulink:
function u = fcn(unused_parameters)
fun = @(x)100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
x0 = [-1,2];
A = [1,2];
b = 1;
coder.extrinsic('fmincon');
x = fmincon(fun,x0,A,b)
u=x(1,1)
And Matlab gave me this error: "Function handles cannot be passed to extrinsic functions.
Function 'MPC' (#23.171.174), line 7, column 13: "fun" Launch diagnostic report."
Thanks for your suggestions!
Akzeptierte Antwort
Weitere Antworten (1)
jaskier222
am 13 Jul. 2017
0 Stimmen
Kategorien
Mehr zu Model Predictive Control Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!