I am modeling a set of pendulums, can anyone explain why the Theta value is coming out the same for all of them when my time and period values are working out like they should?
조회 수: 1 (최근 30일)
이전 댓글 표시
clear, clc, close all
G=9.81; i=1;
while i==1 %Inputting length for longest pendulum and checking if it meets the criteria lin=input('Please input a valid length for the longest pendulum in cm: '); L(1)=lin/100; chk=(12/26)^2 * L(1); if L(1)<=0.9 if chk>=0.05 i=0; end end end
for c=2:15 %Finding the lengths of the other pendulums from the first one. L(c)=(12/(12+c-1))^2 *L(1); end
AngMax=14;
for i=1:15 T(i)=2*pi*sqrt(L(i)/G); t(i,:)=linspace(0,T(i)); Theta(i,:)=AngMax.*sin(t(i,:).*sqrt(G/L(i))); x(i,:)=L(i).*sind(Theta(i,:)); y(i,:)=-abs(L(i).*cosd(Theta(i,:))); end
This is the code I am using, I have tried everything I can think of and no matter what the Theta variable has the same value for all of the pendulums all of the time.
댓글 수: 0
답변 (1개)
Vaibhav Awale
2016년 5월 3일
Hi Brady,
You are getting the same value for Theta variable because your t vector is something like:
t(i,:) = [0, T(i)/100, 2*T(i)/100, ..., T(i)];
Now,
T(i) = 2*pi*sqrt(L(i)/G);
So inside the sin function while calculating Theta(i), the following happens:
sin(t(i,:).*sqrt(G/L(i))) = sin(t(i,:).*(2*pi/T(i))) = sin([0, (2*pi)/100, 2*(2*pi)/100,...,(2*pi)])
Hence, regardless of value of T(i), you are always getting the same values for Theta variable.
If you expect to see value of Theta with respect to time, the time vector needs to be the same for each pendulum (i.e. t(i,:) can't be defined as you have done). Then you will observe that at different time instant, value of Theta is different for different pendulum.
I hope this helps.
Regards,
Vaibhav
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Classical Mechanics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!