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

Lab Assignment 1

1. Write a pseudo-code that determines whether a given integer is a prime number or not.
The algorithm should also warn the user if the input is not an integer. Hint: a prime
number is an integer larger than 1 and is only divisible by itself and by 1.

2. A simply supported concrete beam has a distributed load, w . The cross-section is of


rectangular shape with dimensions b and h. Dimensions b and h both range from 1in to
10in. Write a pseudocode that determines the dimension of the cross-section, accurate to
the 10th decimal place, that can withstand the maximum distributed load, w . The
pseudo-code should search through all possible combinations of b and h, instead of
directly solving for b and h. The beam is assumed to fail when the maximum stress
within the beam reaches the yield strength of the material.
Recall that the maximum stress of a beam is:
My
σ= I
Where y is h/2, M is the maximum moment and I is the moment of inertia about the
horizontal axis.

3. A 3km pipeline is divided into 6 equally spaced segments with different cross-sections’
inner and outer radii. The outer radius starts at 2m and ends at 1m decreasing in a
constant step. The inner radius is always 0.2m smaller than the outer radius. The
cross-section area is given by Acs = π (r2 outer − r2 inner ) .
a. Create a ​row ​vector called ​pipeline_segments ​containing the 6 segments’
length in ​meters ​using Matlab’s built-in function “​ones​” (multiply it by the
necessary scalar).
b. Create a ​row ​vector called ​r_outer ​containing the outer radius values using
the colon operator. Display only the first 3 values in the command window.
c. Create a ​column ​vector called ​r_inner ​containing the inner radius values (use
subtraction and transpose). Display elements 1, 3, and 5.
d. Calculate the cross-section areas and store them in a ​row ​vector called ​A_cs.
e. Calculate the volume ( V segment = ℓsegment Acs ) of each pipeline segment (of each
hollow cylinder) and call it ​V_segment​.
f. The total volume of the pipeline is given by ​Total_V = sum(V_segment).
Display the result in ​format shortE​.
g. Create a 3-by-6 matrix called ​Segment_weights containing the segments’
weight using density values of 8, 050 kg/m3 , 7, 874 kg/m3 , and 2, 700 kg/m3 .
Display the ​5th column​ in ​format short ​the command window.
h. The total weight of the pipeline for each of the densities given above is calculated
via ​Total_W = sum(Segment_weights,2), resulting in a 3-by-1 vector.
Display this vector in ​format long​. Is any of these weights above 4e7 (Return a
logical array)?

4. For the same shape covered in the lab this week:


a. Write a function that takes in the b and h dimensions of the shape and outputs
the moment of inertia about both the X- and Y-axis of the shape.
b. Write a script that calls for the function you wrote in part a and calculate the
moment of inertia about both the X and Y axis, given:
h=12 in
b=[5,7,9,11,13,15,17] in
c. Plot the moment of inertia about the X- and Y-axis against the b values. Label
the axes and provide a title to the graph.

You might also like