% MotionGenesis file: ParticlePendulumMFileForSimulink.txt % Problem: Particle pendulum with air resistance (for Simulink). % Copyright (c) 2009 Motion Genesis LLC. All rights reserved. %------------------------------------------------------------ NewtonianFrame N % Earth RigidFrame B % Massless cable. Particle Q % Particle at end of cable. %------------------------------------------------------------ Q.SetMass( m = 100 kg ) Constant g = 9.8 m/s^2 % Earth's gravitational acceleration Constant L = 50 m % Cable length Constant bAir = 2.0 N*s/m % Air-resistance constant Variable theta'' % Pendulum swing angle Variable Tension % Tension in cable. %------------------------------------------------------------ % Rotation and translation kinematics B.RotateZ( N, theta ) Q.Translate( No, -L*By> ) %------------------------------------------------------------ % Contact and distance forces on Q. Q.AddForce( -m*g*Ny> + Tension*By> - bAir*Q.GetVelocity(N) ) %------------------------------------------------------------ % Form equations of motion with F = m *a ZeroFma[1] = Dot( Q.GetDynamics(), Bx> ) ZeroFma[2] = Dot( Q.GetDynamics(), By> ) Solve( ZeroFma, theta'', Tension ) %------------------------------------------------------------ % Quantities to be output by Algebraic() command. OutputEncode theta deg, theta' rad/sec, theta'' rad/sec^2, Tension Newtons Code Algebraic() ParticlePendulumMFileForSimulink.m( theta, theta' ) %------------------------------------------------------------ Save ParticlePendulumMFileForSimulink.html Quit