Ctufekci

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Lab II Mechanics

Exercise Set 3

Spring 2012

Programming in MATLAB: Scripts and Functions


Problem Solving with MATLAB Scripts 1) A Pratt steel truss is to be designed to support three 50kN loads as shown. The length of the truss is to be 12 m. The height of the truss and thus the angle, , as well as the cross-sectional areas of the various members, are to be selected to obtain the most economical design. Specifically, the cross-sectional area of each member is to be chosen so that the stress in that member is equal to 160 N/mm2 (the allowable stress-). The total weight of the steel, and thus its cost, must be as small as possible. a. Knowing that the density of the steel used is 7800 kg/m3, write a MATLAB script that can be used to calculate the weight of the truss and the cross-sectional area of each load-bearing member located to the left of DE for values of from 20 to 80 using 5 increments. b. Using smaller increments, determine the optimum value of and the corresponding values of the weight of the truss and weight of the cross-sectional areas of the various members. Ignore the weight of any zero-force members. Hand Calculations Consider P = 50 kN, and calculate the support reactions in terms of P. Non-numerical! Use method of joints to formulate force in each member in terms of P and . Formulate the length of each member in terms of b (= 3 m) and . Consider only members to the left of DE since Pratt truss is symmetrical. Are you going to include DE in your calculations? Why? Formulate the area of each member using maximum allowable stress and force found. Formulate the volume of the truss. Exclude zero-force members. Formulate the weight of the truss. Computer Programming For part a. From to with increments of , write a program to calculate following data for each value. o Area of member AB (mm2) o Area of member AC (mm2) o Area of member CE (mm2) o Area of member BC (mm2) o Area of member BD (mm2) o Area of member BE (mm2) o Total weight of the truss (N) For part b. From part a. determine the optimum interval and in that interval calculate above data for smaller increments of . Use MATLABs input command to take in values for P, b, SigmaAll (allowable stress), rho (density), theta1 (starting angle), theta2 (ending angle), delta_theta (increments in theta angle) Name your m-file: first_lastname_truss.m Plot angle versus truss weight and mark optimum point. Show that your program finds the asked parameters.

Dr. C. Tufekci

Page 1 of 2

YTU Mechatronics

Lab II Mechanics

Exercise Set 3

Spring 2012

Writing Your Own Functions with MATLAB 2) The sine of an angle can be approximately calculated from the following series expansion: [ ]

a. Write a MATLAB function in a functional form that uses first 3 terms of the series. return_value = mySinFunc (theta) Find the error of your function with respect to built-in MATLAB function. b. Convert your MATLAB function in the following form: return_value = mySinFunc (theta, err) where theta is angle in degrees and err is a specified error value and return_value is the resulting sine value. Note that the error value is calculated as: | | where sin is the built-in function, whereas Sin is the series expansion. c. Add a flag to plot your sine function against built-in sine function in the range of return_value = mySinFunc (theta, err, plot_flag) If plot_flag is set to 1, the plot is sketched otherwise your function must behave like in part b.

Dr. C. Tufekci

Page 2 of 2

YTU Mechatronics

You might also like