Changing Amplitude with Initial Condition for System of First-Order Differential Equations

3 views (last 30 days)
I have two second-order differential equations that have been converted into a first-order system, with the result (angle vs time) plotted. I would like to change the amplitude of the oscillation to a very small number (10^-5) and observe how changing the relative and absolute tolerance will affect the results.
Basically, this is a model of a double pendulum, and I would like to observe the results for the two modes of this type of function: one with initial conditon theta2 = theta1*sqrt2 and oscillation cos(1.848t), and another with theta2 = -theta1*sqrt2 and oscillation cos(0.765t). How would I go about changing the amplitude/oscillation of this kind of function? Here is what I have so far:
function g = eqns(t,y)
f1 = y(1) %f1 = theta1
f2 = y(2) %f2 = theta2
n1 = y(3) %n1 = thetaprime1
n2 = y(4) %n2 = thetaprime2
L = eye(4)
%these are the coefficients of the equations of motion
L(3,3) = 6;
L(3,4) = cos(f1 - f2);
L(4,3) = L(3,4);
L(4,4) = 7;
%Vector containing the derivatives of the angles and the right side of the equations of motion
M1 = y(3)
M2 = y(4)
M3 = -9sin(f1)-(y(4)).^2*sin(f1 - f2)
M4 = -sin(y(2))+(y(3)).^2*sin(f1 - f2)
g = L/M
g1 = g(1)
g2 = g(2)
dg = [f1 g1 f2 g2]
end
In a different file, which is used to run the code above, I have:
T = [0, 20]
k1 = pi/200 %k = init. condition for angle
k2 = pi/250
s1 = 0 %s = init. condition for derivative
s2 = 0
g0 = [k1 s1 k2 s2]
options = odeset('reltol',1e-05,'abstol',1e-06)
[t,y] = ode45(@eqns,t,g0,options)
plot(t,y(:,1),t,y(:,3));
Any guidance would be appreciated.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!