Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2013-04-07
年龄: 34
帖子: 1
声望力: 0 ![]() |
![]()
function xiaobei()
%clc %clear all global a yyy_fcn=@Newyfun; fcn_integrator=@ode45; w=1; % y0=[0;0;0.2;0.2]; % tspan=0:2*pi/w*0.01:2*pi/w*110; tt=2*pi/w; % options = odeset('RelTol',1e-6,'AbsTol',[1e-6 1e-6]); % options = odeset('RelTol',1e-6,'AbsTol',[1e-6 1e-6]); % options = odeset('RelTol',1e-6,'AbsTol',[1e-6 1e-6]); % options = odeset('RelTol',1e-6,'AbsTol',[1e-6 1e-6]); for a=0.0001:0.0001:1 y0=[0.00001;0.00001;0.2;0.2]; for i=2:100 tspan=(i-1)*tt:tt/100:tt*i; [t,y]=feval(fcn_integrator,yyy_fcn,tspan,y0); y0=y(end, ![]() if i>=60 plot(f,y(end,4),'k.','markersize',1); hold on end end end figure(2) plot(y(:,2),y(:,4)); %调用方程的函数 function dx=NewyFun(x) global a m1=1;m2=0.3;k1=1;k2=1;c1=0.3;c2=0.4;u1=1;u2=1;l=1;f=80; dx=[x(1); x(2); (l-a)*(l-a)*(f-k1*x(1)-c1*x(3)-u1*x(1)*x(1)*x(1))/(m2*a*a+m1*(l-a)*(l-a))-a*(l-a)*(k2*x(2)+c2*x(4)+u2*x(2)*x(2)*x(2))/(m2*a*a+m1*(l-a)*(l-a)); a*(l-a)*(f-k1*x(1)-c1*x(3)-u1*x(1)*x(1)*x(1))/(m2*a*a+m1*(l-a)*(l-a))-a*a*(k2*x(2)+c2*x(4)+u2*x(2)*x(2)*x(2))*dt/(m2*a*a+m1*(l-a)*(l-a))+x4;]; end 运行后报错显示; Error using ==> NewyFun Too many input arguments. Error in ==> 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, odeFcn, ... Error in ==> xiaobei at 19 [t,y]=feval(fcn_integrator,yyy_fcn,tspan,y0); 请问哪里有问题,谢过了! |
![]() |
![]() |