matlab求解泛函微分方程数值解.
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 13:52:42
matlab求解泛函微分方程数值解.
我想用matlab求解一个泛函微分方程的数值解,编了个程序总是运行不出来,
lags=[1];
sol=dde23('ddefun',lags,'history',[0,100]);
plot(sol.x,sol.y);
title('ddefun');xlabel('t');ylabel('y');
legend('y_1','y_2','y_3','y_4',2);
tx=[4.3,4.7];y=deval(sol,tx);hold on;plot(tx,y,'x');
function dydt=ddefun(t,y,Z)
ylag1=Z(:,1);
dydt=[(-0.5)*y(1)-2*y(2)+ylag1(3)
2*y(1)-0.5*y(2)+ylag1(4)
(-0.5)*y(3)-0.5*y(4)+ylag1(1)
0.5*y(3)-0.5*y(4)+ylag1(2)];
function S=history(t)
S=ones(3,1);
原方程是这样的
dy1/dt=-0.5y1-2y2+y3(t-1)
dy2/dt=2y1-0.5y2+y4(t-1)
dy3/dt=-0.5y3-0.5y4+y1(t-1)
dy4/dt=0.5y3-0.5y4+y2(t-1)
还是不对,运行后出现了这样的提示:
In an assignment A(:,matrix) = B,the number of rows in A and B
must be the same.
Error in ==> C:\MATLAB6.5\toolbox\matlab\funfun\dde23.m (lagvals)
On line 656 ==> Z(:,j) = temp(:);
Error in ==> C:\MATLAB6.5\toolbox\matlab\funfun\dde23.m
On line 270 ==> Z = lagvals(t,lags,history,t,y,[],varargin{:});
我想用matlab求解一个泛函微分方程的数值解,编了个程序总是运行不出来,
lags=[1];
sol=dde23('ddefun',lags,'history',[0,100]);
plot(sol.x,sol.y);
title('ddefun');xlabel('t');ylabel('y');
legend('y_1','y_2','y_3','y_4',2);
tx=[4.3,4.7];y=deval(sol,tx);hold on;plot(tx,y,'x');
function dydt=ddefun(t,y,Z)
ylag1=Z(:,1);
dydt=[(-0.5)*y(1)-2*y(2)+ylag1(3)
2*y(1)-0.5*y(2)+ylag1(4)
(-0.5)*y(3)-0.5*y(4)+ylag1(1)
0.5*y(3)-0.5*y(4)+ylag1(2)];
function S=history(t)
S=ones(3,1);
原方程是这样的
dy1/dt=-0.5y1-2y2+y3(t-1)
dy2/dt=2y1-0.5y2+y4(t-1)
dy3/dt=-0.5y3-0.5y4+y1(t-1)
dy4/dt=0.5y3-0.5y4+y2(t-1)
还是不对,运行后出现了这样的提示:
In an assignment A(:,matrix) = B,the number of rows in A and B
must be the same.
Error in ==> C:\MATLAB6.5\toolbox\matlab\funfun\dde23.m (lagvals)
On line 656 ==> Z(:,j) = temp(:);
Error in ==> C:\MATLAB6.5\toolbox\matlab\funfun\dde23.m
On line 270 ==> Z = lagvals(t,lags,history,t,y,[],varargin{:});
改动:
function S=history(t)
S=ones(3,1);
改为 S=ones(4,1);
OVER!
PS.多翻翻help!
function S=history(t)
S=ones(3,1);
改为 S=ones(4,1);
OVER!
PS.多翻翻help!