I have solved a simple pendulum problem (a pendulum driven by a motor at the joint), using ode45. I first defined the function in terms of the state space variables in a file called function1dof.m:
function func = F(t,x) m = 1; g = 10; L = 1; Lc = L/2; I = 0.3333; % kg-m^2
u = 3.8; % Torque in N-m
func = zeros(2,1); func(1) = x(2); func(2) = (3/(m*(L^2)))*(u - m*g*Lc*sin(x(1))); end
Then, I called this function in another script called solver1dof.m:
t0 = 0; tf = 5; x10 = 0; x20 = 0; [t,x] = ode45(@function1dof,[t0,tf],[x10,x20]);
However, when I defined my states such that the system is a first order ODE (so that ode45 would solve it), I realized the output gives the 0th and 1st derivatives, and not the 2nd derivatives. Is there some way I could calculate the 2nd derivative of the angle in this pendulum problem? (Note: The independent variable in this problem is the angle of the pendulum).
Best Answer