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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Assembly에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!