0

我在这里从 matlab 论坛移植我的问题: https ://www.mathworks.com/matlabcentral/answers/871733-validating-mpc-controller-with-parameters?s_tid=srchtitle

我找不到解释如何定义带参数的 MPC 模型的示例。我假设使用细胞会像我尝试使用其他配方一样起作用。

我有一个使用以下脚本构建的 MPC 控制器:

nx = 11;
ny = 11;
nu = 13;
nlobj = nlmpc(nx,ny,nu);
nlobj.Model.NumberOfParameters=28;
nlobj.Model.StateFcn="nonlinear_eom";
% nlobj.Jacobian.StateFcn=???;
Ts=0.4;
p=20;
nlobj.Ts=Ts;
nlobj.PredictionHorizon=p;
nlobj.ControlHorizon=p;

nlobj.Optimization.CustomCostFcn= @(X,U,e,data) Ts*sum(sum(U(1:(p+1),1:4)));

nlobj.Optimization.ReplaceStandardCost=true;


for ct=1:nu
    if ct>=1 && ct<=4
        nlobj.MV(ct).Min=-3;
        nlobj.MV(ct).Min=3;
    elseif ct==5 || ct==7
        nlobj.MV(ct).Min=-1;
        nlobj.MV(ct).Max=1;
    elseif ct==6
        nlobj.MV(ct).Min=-1;
        nlobj.MV(ct).Max=10;
    else
        nlobj.MV(ct).Min=-6;
        nlobj.MV(ct).Max=6;
    end
end

x0 = rand(1,nx);
u0 = rand(1,nu); 
validateFcns(nlobj,x0,u0,params)

其中 params 定义为 1x28 元胞数组。当我将 nlobj 验证为:

validateFcns(nlobj,x0,u0,[],params)

它给了我以下错误:

Error using nlmpc/validateFcns (line 175)
Expecting 30 input arguments but "Model.StateFcn" appears to take 3 inputs.
Error in mpc_validation_test (line 129)
validateFcns(nlobj,x0,u0,[],params)'''

The equation of motion contain 11 states and 13 control variables, so I have no clue where the number 30 is coming from. 
4

0 回答 0