![]() |
各位高手,小弟有一个小程序一直泡不下来,求各位大神帮忙,先谢过了
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); 请问哪里有问题,谢过了! |
所有时间均为北京时间。现在的时间是 14:40。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.