ME 2004, Homework 2 Problem 1 (Cantilever beam with point-load):
The deflection of a cantilevered beam with a point load is
where
E = Young’s Modulus (psi)
I = moment of inertia (in^4) L = Length (in)
a = location of point load (in) W = load (lbf)
Objectives
We wish to study the deflection as function of x for a given set of system parameters. To accomplish this task, we will create three separate M-files (one main program and two functions).
M-file 1
This function M-file should generate a plot of y versus x for a single loading. Indicate the location of the point load on your graph with a triangular symbol (‘v’). The function plots y from x=0 to a first and then plots y from x=a to L. In other words, there should be two calls for fplot() and a single call for plot() (indicating the location of the loading). Hint: Declare two anonymous functions y_1 and y_2 and plot for x=0 to a, and x=a to L respectively.
M-file 2
This function M-file should generate a plot of y versus x for a single loading. Indicate the location of the point load on your graph with a triangular symbol (‘v’). The function plots y from x=0 to L using a single call of fplot(). In other words, there should be one call for fplot() and a single call for plot() (indicating the location of the loading). Hint: Declare two anonymous functions y_1 and y_2. Using the heaviside() built-in function, declare an anonymous function y based on y_1, y_2 and heaviside(). This function y gives the beam displacement x=0 to L.
M-file 3
This script M-file is a driver (main) program that performs the following tasks: 1. Specify the input parameters E,I,L,W, and the loading position a.
y=−Wx2(3a−x), 0xa 6EI
y=−Wa2(3x−a), axL 6EI
Summer 2020
aW y
x
L
function BeamCantPoint_a(E,I,L,a,W)
function BeamCantPoint_b(E,I,L,a,W)
2. Repeatedly call the function ‘BeamCantPoint_a’to create a single graph for a = 0 to 10 in with increments of 2 in. Use a “for” loop (hint: the built-in function length() might be useful). Plot to figure 1.
3. Repeatedly call the function ‘BeamCantPoint_b’ to create a single graph for a = 0 to 10 in with increments of 2 in. Use a “for” loop and plot to figure 2.
This M-file should be named ‘BeamCantPointStudy’.
Use the following parameters
E = 10*10^6;
I = 0.163;
L = 10;
W = 500;
% psi
% in^4
% in
% lb
Problem 2 (Flow speed in inclined pipe-revisted):
Manning’s equation gives the flow speed U (m/s) of water in a rectangular downward sloping pipe:
√𝑆 𝐵𝐻 2/3 𝑈= 𝑛 (𝐵+2𝐻)
where S is the pipe slope, n is the pipe roughness, B(m) is the pipe width and H(m) is the pipe height.
a) Enter the above data into an excel spread-sheet (include column headers).
b) Using xlsread(), load the data into an array n_S_B_H_U.
c) Write and call a function (M-file #1) in your main program (M-file #2) which calculates the flow
speed via Manning’s equation. This function should be one line of executable and not contain any loops! The function (M-file #1) must be declared via:
d) Store the calculated speed in the last column of the array n_S_B_H_U and print the resulting array to the command line in tabular form using fprintf(). Note, the printed table must include a header followed by a single line, data then followed by a single line. Hint: A similar type header might be created via fprintf(1, ‘y(m) \t\t t(s) \n’) followed by fprintf(1, ‘_________________\n’).
e) Create a text-file (using Notepad) containing only the numerical data, read the data using load() and repeat the above. You will have two programs, one using xlsread() and the other using load(). Hint: In Notepad columns are created by using a tab between data values.
Publish your HW programs (only display relevant outputs or inputs, and suppress all other output) and submit a paper copy in recitation. Note, sections may not work if functions are declared locally (i.e. a function declaration at the end of your main program). Therefore, if the problems for which you decide to use sections, declare your functions in a separate m-file stored in the same folder. To received full credit, print outs of your function m-files must also be submitted with the HW.
n
S
B(m)
H(m)
0.036
0.0001
10
3
0.020
0.0002
8
2
0.015
0.0012
20
2.5
0.030
0.0007
25
4
0.022
0.0003
15
3.6
function [U_vector]=manning_flow_speed(n_S_B_H_U_matrix)