How to stop the simulation in one cycle of Simple Pendulum

1 次查看(过去 30 天)
I made the code of simple pendulum which is moved by trq.
However, depending on the amount of torque, it will continue to rotate.
When the pendulum makes one lap, I want to stop and repeat the control.
In other words, after one lap, it was reset to the initial state [0: 0] and the simulation started again.
Please someone help me.
close all;
% parameter of simple pendulum
Length = 1.0; % Length of pendulum
Mass = 1.0; % mass of pendulum
Ts = 0.01; % time step
Theta_Initial = 0; % Initial Value of pendulum's theta
AngularVelocity_Initial = 0; % Initila Value of pendulum's angularVelocity
% call class of pendulum
Pendulum = classPendulum(Length,Mass,Theta_Initial,AngularVelocity_Initial,Ts);
Trq = -10;
% move
% If this is the case, the pendulum will stop at a certain angle and the simulation will end.
% I want to repeat the movement of the pendulum up to a certain angle.
for i = 1:1000
if Pendulum.Theta > -4.8
Pendulum.pstep(Trq);
end
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assembly 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by