Numerical Solution for a system of Two Differential Equations
2 次查看(过去 30 天)
显示 更早的评论
Dear,
I have a robotic system which has 2 outputs: 1- the position of a system. (X) 2- the tilt angel of the robot. (theta)
Following are the 2 equations, one for each output. The input is the voltage V. However, any other symbol is a constant.
We want to use ODE solvers. But we couldn't find an ODE example containing an input. Attached are the photos of the equation.
Your help is appreciated.
equation 1
equation 2
1 个评论
Sam Chak
2021-11-6
编辑:Sam Chak
2021-11-6
Generally, you need to design a feedback control law for the input voltage, V. But first, the ODEs have to rearranged so that the double-dot terms do not appear on the right-hand side of the equation. For example, the following system
can be decoupled to become
which can be expressed in the state space model
where is the input force.
For the general nonlinear system, .
回答(1 个)
Paul
2021-11-6
编辑:Paul
2021-11-6
Because V(t) is an input presumably it can be expressed as a function of time, in which case the simplest appraoch is to just compute it inside odefun(). For example, suppose the differential equation to be solved is
dx/dt = -x(t) + V(t)
where V(t) = sin(t). Then the odefun is
function dxdt = odefun(t,x)
dxdt = -x + sin(t)
end
2 个评论
Paul
2021-11-8
编辑:Paul
2021-11-8
You have two second order differential equations:
xddot = f(thetaddot, thetadot, theta, xddot, xdot, x, V)
thetaddot = g(thetaddot, thetadot, theta, xddot, xdot, x, V)
The first step is to manipulate the equations inot the form
M*[xddot;thetaddot) = h(thetadot, theta, xdot, x, V)
where M is 2x2 and h is 2x1. The equations appear to be linear in the second derivatives, so it should be doable. The Symbolic Math Toolbox can help if don't want to do it by hand.
Next, define a state vector:
z1 = x
z2 = theta
z3 = xdot
z4 = thetadot
With these definitons, odefun would look something like this:
function dzdt = odefun(t,z)
V = % compute V(t) here
dzdt = zeros(4,1);
dzdt(1) = z(3);
dzdt(2) = z(4);
dzdt(3:4) = M\h(z4,z2,z3,z1,V); % assumes M is invertible
end
The state vector, z, is returned from the ode solver, like ode45() or ode23().
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!