Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2009-04-13
帖子: 2
声望力: 0 ![]() |
![]()
各位高手大家好, 我现在用ODE45来解这个微分方程,解出来以后想设置在X(1)+X(3)=0的时候,停止,我现在在尝试使用ODESET=OPTIONS,但是始终有一个错误不明白什么意思 肯定各位高手指教
解方程 function dx=step9(t,x) a=0.5 b=0.5 l=a+b mh=10 m=5 g=9.81 dx=zeros(4,1) dx(1)=x(2); dx(2)=-1/b*(-l^3*mh*sin(-x(3)+x(1))*x(4)^2+l^2*mh*g*sin(x(1))-l^3*m*sin(-x(3)+x(1))*x(4)^2+l^2*m*g*sin(x(1))-m*a^2*l*sin(-x(3)+x(1))*x(4)^2+m*a^2*g*sin(x(1))+l^2*cos(-x(3)+x(1))*m*b*sin(-x(3)+x(1))*x(2)^2-l^2*cos(-x(3)+x(1))*g*sin(x(3))*mh-l*cos(-x(3)+x(1))*g*sin(x(3))*m*a-l^2*cos(-x(3)+x(1))*g*sin(x(3))*m)/(l^2*mh+l^2*m+m*a^2-m*l^2*cos(-x(3)+x(1))^2); dx(3)=x(4); dx(4)=(l^2*cos(-x(3)+x(1))*m*sin(-x(3)+x(1))*x(4)^2-l*cos(-x(3)+x(1))*m*g*sin(x(1))-m*l*b*sin(-x(3)+x(1))*x(2)^2+g*sin(x(3))*mh*l+g*sin(x(3))*m*a+g*sin(x(3))*m*l)/(l^2*mh+l^2*m+m*a^2-m*l^2*cos(-x(3)+x(1))^2); 现在做的ODESET function [value,isterminal,direction]=event1(t,x) theta_ns=x(1) theta_s=x(3) value(1)=theta_ns+theta_s if theta_ns+theta_s=0 isterminal(1)=1 else isterminal(1)=0 end direction(1)=-1 运行指令: options=odeset('event',@event1) t0=0; tf=1; x0=[-0.33;-0.25;0.22;-1] [t,x]=ode45('step9',[t0 tf],x0,options) plot(t,x) 错误 ??? Function 'lower' is not defined for values of class 'function_handle'. Error in ==> lower at 26 [varargout{1:nargout}] = builtin('lower', varargin{:}); Error in ==> funfun\private\odeevents at 32 switch lower(eventFcn) Error in ==> ode45 at 209 [haveEventFcn,eventFcn,eventArgs,valt,teout,yeout,ieout] = ... 希望各位指教 |
![]() |
![]() |