Code covered by the BSD License  

Highlights from
Chebpack

image thumbnail

Chebpack

by

 

15 Jul 2011 (Updated )

The MATLAB package Chebpack solves specific problems for differential or integral equations.

Ex6_delay( n , p , alpha , beta, A, B, K )
function [T,Y,y_coef] = Ex6_delay( n , p , alpha , beta, A, B, K )
% Mackey-Glass equation
%  y'(t)=-alpha y(t)+beta y(t-1)/[1+ y(t-1)^p], t in [0,K]
%   x(t)=x0 for t in [-1,0]
% use: [t,y_val,y_coef]=Ex6_delay(128,10,1/0.1625,12/0.1625,0.5,-1,50);
%      [t,y_val,y_coef]=Ex6_delay(128,10,1/0.1625,12/0.1625,0.5, 1,50);
kind=2;dom=[-1,0];t(:,1)=pd(n,dom,kind);
y_val(:,1)=A+B*t(:,1);
y_coef(:,1)=x2t(y_val(:,1),kind);
for k=2:K+1
    dom=[dom(1)+1,dom(2)+1];
    D=deriv(n,dom);
    A=D+alpha*eye(n);b=x2t(beta*y_val(:,k-1)./(1+y_val(:,k-1).^p),kind);
    A(n,:)=cpv(n,dom(1),dom);b(n)=y_val(n,k-1);
    y_coef(:,k)=A\b;t(:,k)=pd(n,dom,kind);
    y_val(:,k)=t2x(y_coef(:,k),kind);
end
T=reshape(t,n*(K+1),1);Y=reshape(y_val,n*(K+1),1);
%plot(T,Y);grid;xlabel('t');ylabel('y');

Contact us