MATLAB è Simulink íà ðóññêîì

https://hub.exponenta.ru/

Simulink

Simulink

11.

. S-, . :

function [sys,x0,str,ts] = buffer_1(t,x,u,flag)
switch flag,
case 0, % 0 ==> return sizes
[sys,x0,str,ts]=mdlInitializeSizes;
case 2, % 2 ==> return next discrete state
sys=mdlUpdate(t,x,u);
case 3, % 3 ==> return outputs
sys=mdlOutputs(t,x,u);
case 9, % 9 ==> Termination
sys=mdlTerminate(t,x,u);
otherwise % all other flags
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 4; % 4 discrete states to hold the "old" values
sizes.NumOutputs = 1;
sizes.NumInputs = 1;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 0; % at least one sample time is needed
sys = simsizes(sizes);
x0 = zeros(1,4);
str = [];
ts = [];
function sys=mdlUpdate(t,x,u)
sys = zeros(4,1); % initialize sys
sys(4) = x(3); % here we are setting the values for
sys(3) = x(2); % x(4), x(3), x(2), and x(1) respectively, for
sys(2) = x(1); % the NEXT integration step
sys(1) = u;
function sys=mdlOutputs(t,x,u)
sys = sum(x); % output the sum of the past four values
function sys=mdlTerminate(t,x,u)
sys = []; % set []

mdlUpdate , mdlOutputs .

[ ]

 


:


 Orphus