Changing Length of Pendulum while it is in motion

7 ビュー (過去 30 日間)
Yan Koon Ang
Yan Koon Ang 2021 年 1 月 12 日
回答済み: Humberto Ramos 2021 年 3 月 8 日
Hi
I have seen many simulations of pendulums oscillating found on matlab. One such example can be found in this link. The link provides the code to simulate and visualise the oscillation of the pendulum by setting up different initial fixed parameters. I was wondering if it is possible to simulate the length of the rod, attached to the pendulum, changing while the pendulum is in motion( i.e the length of the rod should be able to increase/decrease such that it reaches the target length specified over a fixed period of time). This would also mean that the rate of change of the length of the rod can also be controlled.
Currently, using a ode45 solver, I am able to plot the path of the pendulum's oscillation. This is done through specifying the initial conditions, which are fixed. Hence, is there a way that the length of the rod attached to the pendulum be modified during the oscillation?
Thank you in advance!!!

回答 (2 件)

Mischa Kim
Mischa Kim 2021 年 1 月 12 日
Dear Yan Koon Ang,
this is possible. In the example you are referring to in your question you would have to make the time variable t available in the ode file and then you could do something like this:
function xdot = Equation(t,x)
% Set the input values in order to pass onto ode45
% [...]
L = x(5) * (1 + 0.5*t); % replace by whatever behavior/equation you need
  2 件のコメント
Yan Koon Ang
Yan Koon Ang 2021 年 1 月 12 日
Hi Mischa Kim,
I am new to this, hence could you please elaborate on how I could modify the code to allow the time variable " t " available in the ode file (Animation.m file).
Thank you for your understanding!
function Animation(ivp, duration, fps, movie, arrow)
% [...]
nframes=duration*fps; % Number of Frames
% Solving the Equation using ode45
sol=ode45(@Equation,[0 duration], ivp);
t = linspace(0,duration,nframes);
y = deval(sol,t);
Mischa Kim
Mischa Kim 2021 年 1 月 12 日
The first changes you need to make are in the Equation() function, as pointed out above. Just browsing through the example files in the link you provided you need to adapt the Anmiation() function accordingly:
% Position and Angular velocity
phi = y(1,:)';
dtphi = y(2,:)';
L = ivp(5)*(1 + 0.5*t); % replace by whatever behavior/equation you need
% To set the Range os Phase plane, time vs. depl plots
L is used further below to scale the axis. range is a scalar, L a vector, so, e.g.
range = 1.1*L(1);
There may be more changes to get you exactly what you need, but this should get you started.

サインインしてコメントする。


Humberto Ramos
Humberto Ramos 2021 年 3 月 8 日

カテゴリ

Help Center および File ExchangeClassical Mechanics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by