Clear Filters
Clear Filters

Graphing the movement of a driven damed pendulum

2 views (last 30 days)
Michael
Michael on 20 Mar 2022
Answered: Nipun on 25 Jan 2024
I'm trying to graph the movement of a driven damped pendulum, whose equation of motion is :
I should get something like this :
but with my code I'm getting this: what am I doing wrong?
clear all
gamma=1.06;
g=9.81;L=0.5;m=1;dair=1.225;muair=1.81e-5;R=0.1;
w02=g/L;b=6*pi*dair*muair*R; beta2=b/m;
w=2/3*sqrt(w02);
syms y(t)
[V] = odeToVectorField(diff(y, 2) == gamma*w02*cos(w*t)-beta2*diff(y)-w02*sin(y));
M = matlabFunction(V,'vars', {'t','Y'});
[time,A] = ode45(M,[0 200],[-pi/2 0]);
figure
plot(time,A(:,1))
figure
plot(time,A(:,2))

Answers (1)

Nipun
Nipun on 25 Jan 2024
Hi Michael
I understand that you are facing an issue while plotting movement of a driven damed pendulum where the returned graph deviates from the expected graph. I assume that you are referring to the second graph in this article: https://galileoandeinstein.phys.virginia.edu/7010/CM_22a_Period_Doubling_Chaos.html
I base this answer on the information provided in the above article.
Upon a careful review of your code and the shared article, I believe the constant definitions or values can be revised. Additionally, according to the graph shown, the initial conditions for the pendulum are "[0 0]" since the angluar displacement (phi) at t=0 is 0.
For your reference, I am attaching a code with this answer to plot the movement of a driven damed pendulum. Kindly change the constants as per your setup.
clear all;
gamma=1.06;
w0 = 1.5;
w = 1;
beta = 0.75/2;
% declare a sym system
syms t phi(t)
eqn = diff(phi,2) + 2*beta*diff(phi,1) + w0^2*sin(phi) == gamma*w0^2*cos(w*t);
[V] = odeToVectorField(eqn)
M = matlabFunction(V,'vars', {'t','Y'})
sol = ode45(M, [0 100], [0 0])
plot(sol.x, sol.y(1,:))
grid on
The resulting plot matches the given expected plot.
Hope this helps.
Regards,
Nipun

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!