[T,Y]=ode45(@rigid,[0 1],[rand(15,1)]);
[T,Y]=ode45(@rigid,[0 1],[rand(15,1)]);
plot(T,Y(:,1),'-',T,Y(:,2),'-.',T,Y(:,3),'.',T,Y(:,4),'-',T,Y(:,5),'-.',T,Y(:,6),'.',T,Y(:,7),'-',T,Y(:,8),'-.',T,Y(:,9),'.',T,Y(:,10),'-',T,Y(:,11),'-.',T,Y(:,12),'-.',T,Y(:,13),'.',T,Y(:,14),'-',T,Y(:,15),'.')
M文件:
function dy=rigid(t,y)
c=0.1;
Dy=rand(15,1);
A=[-2 1 1 0 0;
0 -2 1 1 0;
0 0 -2 0 0;
1 1 0 -2 0;
0 0 0 0 0];
for i=1:5
s1=0;
s2=0;
s3=0;
for j=1:5
s1=s1+A(i,j)*y(3*i-2);
s2=s2+A(i,j)*y(3*i-1);
s3=s3+A(i,j)*y(3*i);
end
Dy(3*i-2)= 10*y(3*i-1)-y(3*i-2)+c*s1;
Dy(3*i-1)= 28*y(3*i-2)-y(3*i-1)-y(3*i-2)*y(3*i)+c*s2;
Dy(3*i)= y(3*i-2)*y(3*i-1)-8/3*y(3*i)+c*s3;
end
运行后出现错误:
One or more output arguments not assigned during call to 'C:\MATLAB7\work\rigid.m (rigid)'.
Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173
[neq,tspan,ntspan,next,t0,tfinal,tdir,y0,f0,odeArgs,...
function dy=rigid(t,y) 中是dy下面用的是Dy,不统一.