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!