ode45 with multi functions
显示 更早的评论
Actually i want a problem with ode45, but there is three function which express the problem here is my script: tspan = 0 : 0.001 : 3; y0 = [0;0]; [t,y] = ode45(@nonlinsys, tspan,y0); function f = force(wn_sq,damping,Umax,ydot,y,x_desire) f = wn_sq*(x_desire-y)+ damping*(-ydot);
if f > Umax
f = Umax;
else
f < -Umax
f = -Umax;
end
end
function xd = x_desire(t)
xd = heaviside(t-0.5);
end
function dy = nonlinsys(t,y,wn_sq,damping,Umax,ydot,x_desire) dy(1)=y(2); dy(2) = force. dy = dy'; end
would you please help where the source errors are?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!