主题:求助:运行错误
function dy=Dyt(t,y)
mu=0.1;
a=1;
beta=3;
sigma=0.003;
% N=2500;
% rm=randn(N);
t=[0:0.01:100];
% dt=0.01;
m=randn(size(t));
% rand 均匀分布
% randn 正态分布百噪声
% wgn高斯白噪声
rm=sigma*m;
% B=wgn(1,2500,sigma);
%dy=zeros(2,1);
dy=[];
dy(1)=y(2);
dy(2)=-mu*y(2)+a*y(1)-beta*y(1)^3+rm;
close all
%数据的初始化
% mu=0.1;
% a=1;
% b=1;
% sigma=0.003;
% B=randn(1,2500);
% B=wgn(1,2500,sigma);
t0=0;
tfinal=100;
%方针开始和结束时间
tspan=[t0,tfinal];
% dt=0.01;
%系统初始条件
y0=[0,0];
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4],'InitialStep',1e-1);
[tt,yy]=ode45(@Dyt,tspan,y0,options);
figure(1);
plot(tt,yy(:,1))
xlabel('t'),title('y(1)')%实践历程图
figure(2);
plot(yy(:,1),yy(:,2))%像轨迹
ylabel('y(1)'),ylabel('y(2)')
在输入如下的初始数据:
close all
%数据的初始化
% mu=0.1;
% a=1;
% b=1;
% sigma=0.003;
% B=randn(1,2500);
% B=wgn(1,2500,sigma);
t0=0;
tfinal=100;
%方针开始和结束时间
tspan=[t0,tfinal];
% dt=0.01;
%系统初始条件
y0=[0,0];
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4],'InitialStep',1e-1);
[tt,yy]=ode45(@Dyt,tspan,y0,options);
figure(1);
plot(tt,yy(:,1))
xlabel('t'),title('y(1)')%实践历程图
figure(2);
plot(yy(:,1),yy(:,2))%像轨迹
ylabel('y(1)'),ylabel('y(2)')
之后出现如下错误:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> D:\matlab\work\Dyt.m
On line 18 ==> dy(2)=-mu*y(2)+a*y(1)-beta*y(1)^3+rm;
Error in ==> D:\matlab\toolbox\matlab\funfun\private\odearguments.m
On line 104 ==> f0 = feval(ode,t0,y0,args{:});
Error in ==> D:\matlab\toolbox\matlab\funfun\ode45.m
On line 155 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ...
请高手指教啊!
mu=0.1;
a=1;
beta=3;
sigma=0.003;
% N=2500;
% rm=randn(N);
t=[0:0.01:100];
% dt=0.01;
m=randn(size(t));
% rand 均匀分布
% randn 正态分布百噪声
% wgn高斯白噪声
rm=sigma*m;
% B=wgn(1,2500,sigma);
%dy=zeros(2,1);
dy=[];
dy(1)=y(2);
dy(2)=-mu*y(2)+a*y(1)-beta*y(1)^3+rm;
close all
%数据的初始化
% mu=0.1;
% a=1;
% b=1;
% sigma=0.003;
% B=randn(1,2500);
% B=wgn(1,2500,sigma);
t0=0;
tfinal=100;
%方针开始和结束时间
tspan=[t0,tfinal];
% dt=0.01;
%系统初始条件
y0=[0,0];
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4],'InitialStep',1e-1);
[tt,yy]=ode45(@Dyt,tspan,y0,options);
figure(1);
plot(tt,yy(:,1))
xlabel('t'),title('y(1)')%实践历程图
figure(2);
plot(yy(:,1),yy(:,2))%像轨迹
ylabel('y(1)'),ylabel('y(2)')
在输入如下的初始数据:
close all
%数据的初始化
% mu=0.1;
% a=1;
% b=1;
% sigma=0.003;
% B=randn(1,2500);
% B=wgn(1,2500,sigma);
t0=0;
tfinal=100;
%方针开始和结束时间
tspan=[t0,tfinal];
% dt=0.01;
%系统初始条件
y0=[0,0];
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4],'InitialStep',1e-1);
[tt,yy]=ode45(@Dyt,tspan,y0,options);
figure(1);
plot(tt,yy(:,1))
xlabel('t'),title('y(1)')%实践历程图
figure(2);
plot(yy(:,1),yy(:,2))%像轨迹
ylabel('y(1)'),ylabel('y(2)')
之后出现如下错误:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> D:\matlab\work\Dyt.m
On line 18 ==> dy(2)=-mu*y(2)+a*y(1)-beta*y(1)^3+rm;
Error in ==> D:\matlab\toolbox\matlab\funfun\private\odearguments.m
On line 104 ==> f0 = feval(ode,t0,y0,args{:});
Error in ==> D:\matlab\toolbox\matlab\funfun\ode45.m
On line 155 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ...
请高手指教啊!