Professional Documents
Culture Documents
Lab Assignment 1: Cs Outer Inner
Lab Assignment 1: Cs Outer Inner
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.
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)?