You are on page 1of 4

MEE 314-01 – Fall 2015

Homework #2
Due Wednesday, September 9 at 2:30 pm

Homework Submission Guidelines


 Submit Homework #2 as one continuous diary file. The diary file should be uploaded to Isidore
under the Homework #2 Assignment. Note that NO late assignments will be accepted.
 The diary file should be created with the following command (where you input your first and last
names where appropriate):
>> diary(‘FirstName_LastName_HW2.txt’);
 Please make sure that your diary file does not contain any extra information that will complicate
grading. Delete the extra information from the diary file before submission. Diary files can be
edited in MATLAB or in any other text editor (e.g., Notepad).
 Start the diary file with a comment containing your name and the homework assignment number
(i.e., % FirstName LastName – Homework #2).
 Before the work is shown for each problem, indicate each problem number with a comment (i.e.,
% Problem 2.1).
o The following information is an example of the proper format for Problem 2.1
% Problem 2.1
t = linspace(4,34,6)
t =
4 10 16 22 28 34

Use the following vectors for BOTH Problems 2.1 and 2.2.

𝑡 = [2 5 8 11 14 17 20 23 26]

𝑢 = [−5 −4 −3 −2 −1 0 1]

10
𝑣 = [4.5]
−1

1
2.5
4
5.5
𝑤=
7
8.5
10
[11.5]

Problem 2.1
Create the vectors above using the colon operator. The vectors that you create should be identical to the
vectors shown above (e.g., a row or column vector).

Page 1
MEE 314-01 – Fall 2015
Homework #2
Due Wednesday, September 9 at 2:30 pm

Problem 2.2
Create the vectors above using the linspace function. The vectors that you create should be identical to
the vectors shown above (e.g., a row or column vector).

Problem 2.3
Create the following matrices using either the zeros or ones functions in MATLAB.
 Z – matrix containing 6 rows and 3 columns of all elements equal to 0
 Y – matrix containing 2 rows and 5 columns of all elements equal to 1
 X – column vector of 5 rows of all elements equal to 8
 W – row vector of 9 columns of all elements equal to 5/6

Problem 2.4
There are several different ways to generate the following matrix in the MATLAB command line. Generate
the matrix twice using at least 2 different methods. HINT 1: How could you use the colon operator or
linspace? HINT 2: Do the numbers follow a pattern in the rows or columns of the matrix?

6 −10 0
𝐴 = [4 −5 3.5]
2 0 7

Problem 2.5
Using the A matrix you created in Problem 2.4, display the following information to the screen.
The third column of A
The element in the third row and second column of A
The first row of A

HINT: Use the MATLAB code below to display the element in the first row and second column of A:
A(1,2)
ans =
2

Problem 2.6
Modify the A matrix you created in Problem 2.4 to contain the following information. Display each
modification to the screen.
Modify the first column to have all elements equal to 1.
Modify the second row, second column to be equal to 15.
Modify the element in the first row, third column to be equal to 3/4.

HINT: Use the MATLAB code below to modify A so that the element in the first row and second column is
equal to 10.
A(1,2) = 10
A =

Page 2
MEE 314-01 – Fall 2015
Homework #2
Due Wednesday, September 9 at 2:30 pm

6.0000 10.0000 4.0000


-10.0000 -4.0000 2.0000
6.0000 8.5000 11.0000

Problem 2.7
Create a row vector c with elements that increment by 4 starting at 5 and ending with 29. Perform the
following mathematical operations in MATLAB. Use the dot operator only where it is necessary. HINT:
You may need to use the dot operator and/or parentheses for some of the mathematical operations.

2 5.5𝑐
𝑑= 𝑔=
𝑐3 𝑐 + 10

𝑐2 𝑐 + 21
𝑒= ℎ=
10 1.5𝑐

1 𝑖 = 6(𝑐 + 3)
𝑓=
4+𝑐

Solution:
d = 0.0160 0.0027 0.0009 0.0004 0.0002 0.0001 0.0001

e = 2.5000 8.1000 16.9000 28.9000 44.1000 62.5000 84.1000

f = 0.1111 0.0769 0.0588 0.0476 0.0400 0.0345 0.0303

g = 1.8333 2.6053 3.1087 3.4630 3.7258 3.9286 4.0897

h = 3.4667 2.2222 1.7436 1.4902 1.3333 1.2267 1.1494

i = 48 72 96 120 144 168 192

Problem 2.8
The van der Waals equation can be applied to describe the relationship between real gases over a range
of temperature and pressure values.
𝑛2 𝑎
(𝑃 + 2 ) (𝑉 − 𝑛𝑏) = 𝑛𝑅𝑇
𝑉
where 𝑃 is the pressure (217.12 atm)
𝑛 is the number of moles (2 mol)
𝑉 is the volume (1 Liter)
𝑎 is a gas-specific constant (L2-atm/mol2)
𝑏 is a gas-specific constant (L/mol)
𝑅 is the ideal gas constant (0.0821 L-atm/mol-K)

Page 3
MEE 314-01 – Fall 2015
Homework #2
Due Wednesday, September 9 at 2:30 pm

Use the following information for 4 gases:


Compound 𝑎 (L2-atm/mol2) 𝑏 (L/mol)
He 0.03412 0.02370
Ar 1.345 0.03219
O2 1.360 0.03803
CO2 3.592 0.04267

Create variables for each of the constants defined above and vectors containing the data for 𝑎 and 𝑏. Use
the van der Waals equation to solve for the temperature 𝑇 for each gas. Use the dot operator and
complete the calculation for 𝑇 in one line. Using the appropriate MATLAB built-in functions, calculate
the maximum, minimum, average, and standard deviation of the temperatures stored in 𝑇.

Solution:
T =

1.0e+03 *

1.2604 1.2678 1.2523 1.2895

Page 4

You might also like