扰动观察法

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

function [sys,x0,str,ts,simStateCompliance] = PO_MPPT_Boost(t,x,u,flag)

switch flag,

case 0,

[sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes;

case 1,

sys=mdlDerivatives(t,x,u);

case 2,

sys=mdlUpdate(t,x,u);

case 3,

sys=mdlOutputs(t,x,u);

case 4,

sys=mdlGetTimeOfNextVarHit(t,x,u);

case 9,

sys=mdlTerminate(t,x,u);

otherwise

DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag));

end

function [sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes

sizes = simsizes;

sizes.NumContStates = 0;

sizes.NumDiscStates = 3;

sizes.NumOutputs = 1;

sizes.NumInputs = 2;

sizes.DirFeedthrough = 1;

sizes.NumSampleTimes = 1; % at least one sample time is needed

sys = simsizes(sizes);

x0 = [0,0,0.5];%[U I Uref]

str = [];

ts = 1e-6;

simStateCompliance = 'UnknownSimState'; % end mdlInitializeSizes

function sys=mdlDerivatives(t,x,u)

sys = [];

% end mdlDerivatives

function sys=mdlUpdate(t,x,u)

DU=0.001; %步长

dU=u(1)-x(1);

dP=u(1)*u(2)-x(1)*x(2);

if dP>0

if dU>0

Uref=x(3)+DU;

Uref=x(3)-DU;

end

elseif dP<0

if dU>0

Uref=x(3)-DU;

else

Uref=x(3)+DU;

end

else

Uref=x(3);

end

if Uref>=1

Uref=1;

end

if Uref<=0

Uref=0;

end

x(1)=u(1);

x(2)=u(2);

x(3)=Uref;

sys = [x(1),x(2),x(3)];

% end mdlUpdate

function sys=mdlOutputs(t,x,u)

% end mdlOutputs

function sys=mdlGetTimeOfNextVarHit(t,x,u)

sampleTime = 1; % Example, set the next hit to be one second later. sys = t + sampleTime;

function sys=mdlTerminate(t,x,u)

sys = [];

% end mdlTerminate

相关文档
最新文档