毕设用matlab进行演化博弈数值分析总是出错,不能运行,求大神指导
Untitled2
错误使用 nargin
错误: 文件:dfun.m 行:30 列:4
未结束的 %{ 块。使用 %} 终止。
出错 odearguments (line 60)
if (nargin(ode) == 2)
出错 ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
出错 Untitled2 (line 3)
[T,Y]=ode45('dfun',[0:20],[0.1,0.3]);
函数 dfun.m
function dy = dfun(t,y)
%%{
G1=0.5;
G2=1;
P1=0.5;
P2=1;%%}
%{
G1=0.5;
G2=1;
P1=1;
P2=0.8;%}
%{
G1=1;
G2=0.5;
P1=0.5;
P2=1.5;%}
%{
G1=20;
G2=0.5;
P1=0.5;
P2=30;%}
%{
G1=0.6;
G2=0.3;
P1=1.2
P2=0.8;%}
dy=zero(2,1);
dy(1)=y(1)*(1-y(1))*(G2*y(2)-G1);
dy(2)=y(2)*(1-y(2))*(P2*y(1)-P1);
end
主程序 Untitled2.m
clear;
subplot(2,2,1)
[T,Y]=ode45('dfun',[0:20],[0.1,0.3]);
plot(T,Y(:,1),'*');
hold on;
plot(T,Y(:,2),'-');
subplot(2,2,2)
[T,Y]=ode45('dfun',[0:20],[0.3,0.5]);
plot(T,Y(:,1),'*');
hold on;
plot(T,Y(:,2),'-');
subplot(2,2,3)
[T,Y]=ode45('dfun',[0:20],[0.5,0.7]);
plot(T,Y(:,1),'*');
hold on;
plot(T,Y(:,2),'-');
subplot(2,2,4)
[T,Y]=ode45('dfun',[0:20],[0.7,0.9]);
plot(T,Y(:,1),'*');
hold on;
plot(T,Y(:,2),'-');
求指导