Module 4: Modular Programming/Connect

C onnecting the concept with practice.

A rough, rule of thumb, would be to limit the length of each MATLAB function to one screen of commands, roughly 20 to 30 lines of MATLAB programming code. As an illustration of the usefulness of this design, you will be asked to use the instructor provided function (from Extend section of Module 3) getinput to handle the User Interface for this exploration.

The problem must first be specified:

  1. Given the pin-join truss diagram below:
  2. Write a MATLAB script (runtruss.m to solve the statically determinate trust with pin joints by forming the Ax = b linear system of equations corresponding to the trust.
    In this statically determinate trust with pin joints, the tension (Fi) in each member can be obtained from the matrix equation below:
               INPUT1             INPUT2   INPUT1 lbs pushing down
                 |                 /-\           on joint 2
                \-/     F4          |       INPUT2 lbs pulling up
                (2)----------------(4)           on joint 4
                /| .pi/6            |\
               / |   .              | \<-- pi/4
              /  |pi/3 .            |  \
             /   |       . F5       |   \
         F1 /pi/4|         .        |    \F9
           /     |F3         .      |F7   \
          /      |             .    |      \
         /       |               .  |       \
        /   F2   |        F6       .|   F8   \
      (1)-------(3)----------------(5)-------(6)
      / \                           |        / \
     /   \                         \ /      /   \    INPUT3 lbs pulling
    -------                         -      -------   down on joint 5
     fixed                       INPUT3   on rollers
    
    
    Your script should prompt the user to provide INPUT1, INPUT2, INPUT3 above and check that they are in the appropriate range, between the value 500 to 1000, using the instructor provided function getinput.m
  3. With three input values and two output values (matrix A, and right hand side vector, b), write setup.m to create the linear system.

    Since your output variables are mostly zeros, an effective technique would to initialize A and b to be a zero matrix and vector, respectively, with the MATLAB zero command (p. 40), and then reset the appropriate elements of A and b using the sine and cosine of the known angles in our truss diagram and the user provided Forces on truss joints (2), (4), and (5) in our diagram.

    More detail on the form of this matrix.

  4. Your main script should then solve the equations, A x = b, with the MATLAB command for matrix left division (p. 95).

    x = A \ b

  5. The final task will be to output the solution.

See the Apply section in lab Wednesday, Feb. 18, for final details on this programming assignment.

Page author: Dr. Kris Stewart
URL: http://www.stewart.cs.sdsu.edu/cs205/module4/Connect.html
Last updated: Feb. 18,1998