Filter löschen
Filter löschen

Graphing the movement of a driven damed pendulum

2 Ansichten (letzte 30 Tage)
Michael
Michael am 20 Mär. 2022
Beantwortet: Nipun am 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))

Antworten (1)

Nipun
Nipun am 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

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by