错误功能中止了matlab

时间:2015-04-02 16:04:06

标签: matlab embedded simulink

您好,我正在使用matlab在simulink中运行模型,我正在接受此错误

  

使用run时出错(第28行)调用MATLAB函数中止:第一个   " mpc"的输入参数命令必须是以下之一:   LTI对象,IDMODEL对象或模型和偏移的结构。   块子系统2 /控制工厂(#38)执行时:状态期间   操作

我带错误的embedeed块包含代码

function w0u  = MPC(p,x,Sb_bus,Sb,vt,q,theta0,ku,xs,u,vf,KvP,KvI,Kp,Ki,Kd,Droop,DroopAvr,v0,wb,r,t0,umaxnow,time,samplingsTime,Rn,Qn,Rw,Qw,ud,uMinMPC,uMaxMPC,udMaxMPC,wmin,wminw,wmax,wmaxw,tFLR,aFLR,genset3connected,debuggingfile,mpcOn,mpcValSaveTime,mpcValFileName,useUMaxNow,wNLstart)

coder.extrinsic('mpc');
w0u = zeros(2,1);
[w0u] = mpc(p,x,Sb_bus,Sb,vt,q,theta0,ku,xs,u,vf,KvP,KvI,Kp,Ki,Kd,Droop,DroopAvr,v0,wb,r,t0,umaxnow,time,samplingsTime,Rn,Qn,Rw,Qw,ud,uMinMPC,uMaxMPC,udMaxMPC,wmin,wminw,wmax,wmaxw,tFLR,aFLR,genset3connected,debuggingfile,mpcOn,mpcValSaveTime,mpcValFileName,useUMaxNow,wNLstart);

end

函数mpc是

function [w0u] = mpc(p,Sb_bus,Sb,vt,q,x,theta0,ku,xs,u,umaxnow,vf,KvP,KvI,Kp,Ki,Kd,Droop,DroopAvr,v0,wb,r,t0,time,samplingsTime,Rn,Qn,Rw,Qw,ud,uMinMPC,uMaxMPC,udMaxMPC,wmin,wminw,wmax,wmaxw,tFLR,aFLR,genset3connected,debuggingfile,mpcOn,mpcValSaveTime,mpcValFileName,useUMaxNow,wNLstart)
persistent tupdated w0set
eml.extrinsic('saveVariables');
H = [10; 7];
D = [.02;.025];
if (isempty(tupdated))
    % Initialize variables
    tupdated = time;
    w0set = wNLstart;
elseif (time < t0)
    % Wait until t0
elseif (mpcOn == 0)
    % If turned off, do nothing.
elseif (time >= tupdated + samplingsTime)
    % Update w0
    Pbus = sum(p.*Sb)/sum(Sb);
    Qbus = sum(q.*Sb)/sum(Sb);
    pFLR = aFLR*Sb(end)/Sb_bus*Pbus;

    X = [Pbus;Qbus;x];
    u0 = u;
    udw = ud(1);
    %% Calculate the state space equations
    [A B B0 Cu Du ~, ud] = makeLinearSystem(H,D,p,Sb_bus,Sb,q,X,vf,vt,theta0,ku,xs,u0,wb,r,KvP,KvI,Kp,Ki,Kd,Droop,DroopAvr,w0set,v0,samplingsTime,ud);
    [Aw Bw B0w Cuw Duw ~, udw] = makeLinearWorstCaseSystem(H,D,p,Sb_bus,Sb,q,X,vf,vt,theta0,ku,xs,u0,wb,r,KvP,KvI,Kp,Ki,Kd,Droop,DroopAvr,w0set,v0,samplingsTime,genset3connected,pFLR,udw);

    %% Discretize
    if(genset3connected)
        % Discretize system for normal case
        [Ad Bd B0d] = makediscrete(A,B,B0,samplingsTime);
        % Discretize system after FLR reacts
        [AdFLRp, ~, ~] = makediscrete(Aw,Bw,B0w,samplingsTime-tFLR);
    else
        % Sets Ad, Bd, B0d and AdFLRp to remove compilation error (matrices
        % must have the same size for all cases)
        Ad = A;
        Bd = B;
        B0d = B0;
        AdFLRp = Aw;
    end
    % Discretize system for failure case
    [Adw Bdw B0dw] = makediscrete(Aw,Bw,B0w,samplingsTime);

    %% Find input optimal
    [dw0opt PHI PSI dw] = findInput(X,Ad,Bd,B0d,Cu,Du,Adw,Bdw,B0dw,Cuw,Duw,AdFLRp,pFLR,Rn,Qn,Rw,Qw,ud,udw,u,umaxnow,uMinMPC,uMaxMPC,udMaxMPC,wmin,wmax,wminw,wmaxw,p,Sb,genset3connected,time,debuggingfile,useUMaxNow);

    %% Save internal values for plotting
    if(mpcValSaveTime >= time && mpcValSaveTime< time + samplingsTime)
        saveVariables(mpcValFileName,PHI,PSI,dw)
    end
    w0set = w0set + dw0opt;
    tupdated = time;
end

w0u =w0set;

end

我必须做什么?

0 个答案:

没有答案