Difference between revisions of "Matlab Primer"

From Sean_Carver
Jump to: navigation, search
Line 5: Line 5:
 
This class is about MATLAB, not about deriving equations.  So I am just going to give you the equations for the PENDULUM.  There is still a lot to do to get it into MATLAB.
 
This class is about MATLAB, not about deriving equations.  So I am just going to give you the equations for the PENDULUM.  There is still a lot to do to get it into MATLAB.
  
====Pendulum on a movable support====
+
===Pendulum on a movable support===
 
This example comes from Wikipedia (copied legally).  Consider a pendulum of mass ''m'' and length ''ℓ'', which is attached to a support with mass ''M'' which can move along a line in the ''x''-direction. Let ''x'' be the coordinate along the line of the support, and let us denote the position of the pendulum by the angle ''θ'' from the vertical.  
 
This example comes from Wikipedia (copied legally).  Consider a pendulum of mass ''m'' and length ''ℓ'', which is attached to a support with mass ''M'' which can move along a line in the ''x''-direction. Let ''x'' be the coordinate along the line of the support, and let us denote the position of the pendulum by the angle ''θ'' from the vertical.  
  
Line 16: Line 16:
 
Your homework and class exercise for today is to implement this model.  
 
Your homework and class exercise for today is to implement this model.  
  
====Pendulum on a fixed support====
+
===Pendulum on a fixed support===
 
Together we are going to implement a simpler model with support fixed and unmovable.  You can see what the equations for this are easily.  Just plug in
 
Together we are going to implement a simpler model with support fixed and unmovable.  You can see what the equations for this are easily.  Just plug in
  

Revision as of 18:11, 3 November 2012

Today's lecture will be on MATLAB and PENDULA (plural of PENDULUM). Your next lab assignment motivated the topic.

My name is Sean Carver; I am a research scientist in Mechanical Engineering. I have been programming in MATLAB for almost 20 years and programming computers for almost 30 years.

This class is about MATLAB, not about deriving equations. So I am just going to give you the equations for the PENDULUM. There is still a lot to do to get it into MATLAB.

Pendulum on a movable support

This example comes from Wikipedia (copied legally). Consider a pendulum of mass m and length , which is attached to a support with mass M which can move along a line in the x-direction. Let x be the coordinate along the line of the support, and let us denote the position of the pendulum by the angle θ from the vertical.

Sketch of the situation with definition of the coordinates (click to enlarge)
\ddot\theta + \frac{\ddot x}{\ell} \cos\theta + \frac{g}{\ell} \sin\theta = 0.\,

See http://en.wikipedia.org/w/index.php?title=Lagrangian_mechanics&oldid=516894618 for a full derivation.

Your homework and class exercise for today is to implement this model.

Pendulum on a fixed support

Together we are going to implement a simpler model with support fixed and unmovable. You can see what the equations for this are easily. Just plug in

\ddot x = \dot x = x = 0

The second term drops out:

\ddot\theta + \frac{g}{\ell} \sin\theta = 0.\,