Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

MATLAB Problems Programming 1

The document outlines a series of MATLAB problems for a civil engineering course, focusing on topics such as Taylor series, geometric series, stock price analysis, and soil volume calculation. Each problem includes specific tasks such as writing scripts to calculate values, analyze stock transactions, and estimate soil volume using the average end area method. The problems are designed to enhance students' programming skills and understanding of engineering concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MATLAB Problems Programming 1

The document outlines a series of MATLAB problems for a civil engineering course, focusing on topics such as Taylor series, geometric series, stock price analysis, and soil volume calculation. Each problem includes specific tasks such as writing scripts to calculate values, analyze stock transactions, and estimate soil volume using the average end area method. The problems are designed to enhance students' programming skills and understanding of engineering concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

College of Engineering and Computing

Department of Civil and Environmental Engineering


CGN 2420 - Computer Tools for Civil Engineers

Additional Problems - MATLAB

Problem 1

a) Write a program in a script file that determines 𝑒x by using the Taylor series
representation. Try to determine the value of e with your code.

𝑥
𝑥𝑛 𝑥2 𝑥3
𝑒 =∑ =1+𝑥+ + +⋯
𝑛! 2 6
𝑛=0

b) How many terms are needed to have an error smaller than 0.0001?
Try also with 𝑒2, 𝑒-4, and 𝑒21.

Problem 2

The sum of a geometric series converge to a finite number when the ratio is less than 1. This is
because the terms tend to zero as the number of terms increases.

a) Use a for loop to determine and display the first 15 terms in the geometric series
Li = a r(i - 1), for i = 1, 2, 3, . . .
where Li is the ith term in the series, a is the first term, and r is the common ratio.
For this problem a = 8 and r = 1/2.
b) Use a for loop to determine the sum of the first 15 terms in the geometric series given in
part a.
𝑎
c) Show that as you increase the number of terms the sum converges to
(1−𝑟)
Use a while loop to stop the program when the sum converges to a finite value. This will
occur when the terms become very small so they are not significant to the sum anymore.
Problem 3

The price, in dollars, of a certain stock over a 15-day period is given in the following array:
price_K = [18, 19, 18, 22, 21, 25, 19, 20, 17, 16, 21, 27, 29, 30, 28]
Suppose you owned 1000 shares at the start of the 15-day period, and you bought 100 shares
every day the price was below $20 and sold 100 shares every day the price was above $25.

a) Write a program to compute the total number of shares you own after the 15 day.
b) Modify the program to determine and display:
▪ Amount you received from the sale of shares
▪ Amount you spent in buying shares
▪ The net change in the worth of your portfolio

Problem 4

The arrays price_A and price_K given below contain the price in dollars of two stocks over 15
days.

a) Write a program to determine how many days the price of stock A was below the price of
stock K.

price_A = [16, 13, 22, 21, 25, 19, 17, 20, 27, 28, 25, 22, 19, 21, 26]
price_K = [18, 19, 18, 22, 21, 25, 19, 20, 17, 16, 21, 27, 29, 30, 28]

b) Suppose you lose the difference in the price of the stocks multiplied by 10 every day the
price of stock A is below the price of stock K. On the other hand, you gain the difference
in the price of the stocks multiplied by 20 every day the price of stock A is above the
price of stock K. Modify your program so the output includes the total amount gained and
the total amount lost.

Problem 5

A three dimensional soil volume between two points is known as a soil prism, see figure below.
The prismatic volume must be calculated in order to estimate hauling requirements during
excavation works. One common method to calculate the volume is the average end area method.
With this method, the volume is calculated by averaging
the two end areas and multiplying by the prism length.

(𝐴1 + 𝐴2 )
𝑉=𝐿
2

When the cut area is known at different consecutive stations,


and the distance between stations can be determined,
then the volume of successive prisms is calculated to
estimate the total soil volume to be removed.

Write a code in MATLAB that loads the data below with the cut areas at different stations and its
corresponding locations. Then using the average end area method estimate the soil volume
between stations and return the total volume to be removed during the excavation.

STATION 1 2 3 4 5 6 7 8 9 10 11 12
Location (ft) 0 6 13 16 20 24 27 31 36 42 47 50
Area (ft2) 219 657 1070 1303 1266 1355 1291 1133 954 538 199 47

You might also like