⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 int2.m

📁 一个时滞系统的工具箱
💻 M
字号:
function rez=int2(sb,se,t,tt,xt,initfun,F,num);
%INT2  calculates the integrals of function F(y(s)) 
%      from -tau(t) to 0 over variable s, included in the right
%      hand of a system of functional differential equations
%      to be solved numerically.
%      For calculations INT2 uses initial function as well arrays
%      tt, xt used for construction of degenerate cubic splines.
%      INT2 implements Simpson's method of the integration.
%      INT2 is used in special functions where user describes
%      the system in order to solve it by the program dde45.
%      For details see descriptions.


if nargin < 8
  num=1:size(xt,2);
end;

% Initialization
M=20;            % The number of partitions
h=2*(se-sb)/M;
j=0:M; 
tj=sb+0.5*h*j;   % Array of internal division of the segment [sb, se]
temp2=zeros(length(num),M+1);

% Calculation of integrand at the internal points
% of the segment [sb, se].
k=find(t+tj<=tt(1));
len=length(k);
if ~isempty(k)
   for i=1:len 
     s=t+tj(k(i));
     temp1=eval(initfun);
     temp2(:,k(i))=temp1(num,:);
   end;
end;
k=(len+1):(M+1);
if ~isempty(k) 
  temp2(:,k)=Spline3(tt,xt(:,num),tj(k)+t)';
end;

s=temp2(:,1);
F1=eval(F);
x1=zeros(length(F1),M+1);
x1(:,1)=F1;
for i=2:M+1
    s=temp2(:,i);
    x1(:,i)=eval(F);
end;

% The final summation
summ=x1(:,1)+4*sum(x1(:,2:2:M)')'+2*sum(x1(:,3:2:M-1)')'+x1(:,M+1);
rez=summ*h/6;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -