You are on page 1of 12

MAE 294: Homework #1

Instructor: Mark Miner


Assigned January 9, 2013
Due 12:00pm, January 11, 2013
I suggest you try these in MATLAB. In homework assignments as in your code,
problems proceed sequentially and may call for a previously dened variable.
Deliverables: Answers to the following questions. Submit via Blackboard, either
in the response box or by attaching a le containing your answers.

Problem 1
1.1

Variables

(5pts) Are the Following Variable Names Valid? (T/F)

1) IsBad VarName
2) 2CoolForSchool
3) IsBad?VarName
4) or
5) fourier
6) elif
7) sqrt
8) break
9) yourself
10) else

1.2

(2pts) Are Variable Names a and b Equivalent? (T/F)

1) a: sub 1
2) a: PapaJohn

1.3
1)
2)
3)
4)
5)
6)

b: sub l
b: papajohn

(3pts) How Big Are These Variables? (row, column)

A = [1, 2, 3; 4, 5, 6]
b = [1, 2; 3, 4; 5, 6]
c = [123; 456]
d = [1; 2; 3; 4; 5; 6]
E = [A; A]
F = [A, c]

MAE 294: Homework #2


Instructor: Mark Miner
Assigned January 11, 2013
Due January 16, 2012
Deliverables: Responses to the following questions, submitted via BlackBoard.

Problem 1

(2pts) Numbers

Given the following IEEE-754-dened values (in base-10, dont worry), tell me what
number is constructed:
a)s=1, m=31416, b=10, e=-4
b)s=0, m=64, b=2, e=-6

Problem 2
2.1

Logicals

(1pt) Logical variables appear in the Workspace window


as a:

a) Checkbox
b) Cube
c) Square with lower case ab in it
d) Doubly-bisected square

2.2

(3pts) Given R=0, S=0, T=1, evaluate the following (1/0


for true/false):

a) R & T
b) S | T
c) S >= T
d) (R & S) < T
e) R =T
f) R == S

Problem 3

(6pts) Arrays

Given A=[ 16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1], nd the following:


a) max(min(A,[],2))
b) min(max(A,[],2))
c) mean(max(A,[],1))
d) max(mean(A,1))
e) max(sum(A))
f) sum(max(A))

MAE 215: Homework #3


Instructor: Mark Miner
Assigned January 16, 2013
Due 11:59am, January 18, 2013
Deliverables: Responses to the following questions.
Optional Deliverables: A functioning MATLAB script which prints the responses.
For each of the following questions, indicate how you obtained your answer (MATLAB, calculator, etc.). You may submit a script which performs the calculations (I
guarantee this is the easiest way to do them), though if you do, comment your code
so I can follow the logic. Submit functioning, commented, M-files named as follows:
myASURITE hw3.m, for example, mjminer hw3.m

Problem 1

Polynomial Roots

Given the polynomial:


y = 0.01x5 0.20x4 + 0.1x3 x + 10

1.1

(3pts) Real Roots

Solve for the three real roots.

1.2

(2pts) Imaginary Roots

Solve for the two imaginary roots (note that they are a pair of complex conjugates).

.........
Problem 2

(10pts) Triangles

Consider a generic right triangle abc :


H

HH c
H
HH

H
H

b
Given the information in Table 1, calculate the area, perimeter, and lengths of
sides b and c of each of the triangles.
Triangle Side a (m) Angle ac (Degrees)
1
1
30
2
1
50
3
2
20
4
3
45
5
5
60

.........

MAE 215: Homework #4


Instructor: Mark Miner
Assigned January 18, 2013
Due 11:59am, January 23, 2013
This assignment requires you to use the hw4 starter.m le, available on the
HW assignment page. Rename it as asuid hw4.m and perform the required modications. Your submission MUST execute in order to receive full credit.

Problem 1
1.1

Functions Within Functions

(10 pts) Euler

Save and rename the hw4 starter.m le, and use it as the beginning of your code.
Recall Eulers formula from analytical calculus: eix = cos(x) + i sin(x), where i is
the imaginary unit. A slight rearrangement yields:
sin(x) = i cos(x) i eix

(1)

Create a nested subfunction within the starter le that accepts one input argument
x (which may be a vector) and returns the sin function dened as above. Call
this function for input arguments of x=0:pi/4:2*pi and return the results to the
command window.

1.2

(5 pts) Euler Error

Subtract the standard MATLAB denition of sin(x) from the above denition for
the same input arguments and return the results to the command window. Think
about what this gure means for MATLABs denition of sine.

1.3

(10 pts) Anonymous

Corollaries of Eulers formula are the hyperbolic functions, sinh and cosh, which are
dened as:
ex ex
ex + ex
cosh(x) =
(2)
2
2
Using the same starter function, add anonymous functions mysinh(x) and mycosh(x)
which perform the calculations above. Evaluate these functions for input arguments
of x=-0.5:0.1:0.5 and return the output of both functions to the command window.
sinh(x) =

.........

MAE 215: Homework #5


Instructor: Mark Miner
Assigned January 23, 2013
Due 11:59am, January 25, 2013
Deliverables: One M-le which accepts two inputs (low and high temperatures) in any
of the four units discussed, and yields two outputs (dimensionless eciency and heat ux in
W/m2 ).

Problem 1

Tricky Temperatures

Certain common temperature scales are relative, that is, with a zero dened against an arbitrary value. Others are absolute, taking their zero at the theoretical point where molecular
motion stops. The following functions must ask the user to specify the units on the inputs, with your code making the necessary adjustments to compute correctly. Faulty inputs
must be rejected (no complex temperatures and only certain scales admit negative). You
may either admit or reject vectors. You may use either if/else or switch/case structures. Use the menu command to call for inputs. Users must be oered options of degrees
Fahrenheit, Centigrade, Kelvin or Rankine. If in doubt about temperature scales, consult
Wikipedia or WolframAlpha. As always, name your function like asurite hw5.m.

1.1

(10pts) Carnot Eciency

A heat engine may not have a thermodynamic (1st Law) eciency greater than that of the
theoretical Carnot cycle. This cycle represents the ideal machine taking innite time to
move energy from a hot reservoir at TH to a cold reservoir at TC (perhaps the combustion
chamber of a turbine and ambient air). The Carnot/ideal eciency is dened using absolute
temperatures as:
TC
ideal = 1
(1)
TH
Write a function which accepts two inputs, TH and TC , and outputs the correct Carnot
eciency. Eq. 1 must be given absolute units of temperature. Your function must accept
any of the four input units above.

1.2

(10pts) Radiation

The blackbody radiation heat ux between two innite plates (or any pair of objects with
view factors of unity) is given by:
q = (TH4 TC4 )

(2)

where is the Stefan-Boltzmann constant, and TH and TC are the absolute temperatures
of the interacting black bodies. Given TH and TC as in Q1.1, calculate the output of q.

W
,
regardless
of
the
input
units.
Consult
Wikipedia,
The output must be in units of m
2
WolframAlpha, or a heat transfer book if you need help nding values of in appropriate
units.

MAE 215: Homework #6


Instructor: Mark Miner
Assigned January 25, 2013
Due 11:59am, January 30, 2013
Deliverables: One working, commented function or script that accomplishes all
objectives. As always, name it as asuid hw6.m.

Problem 1
1.1

Loops

(10pts) while Loops

The Taylor series allows the approximation of a function at unknown xvalues in the
region of a known value. Thus, if a is the known value and x is near a:
df 
d2 f  (x a)
+ ...

(x

a)
+
a
a
dx
dx2
2
which can be written compactly as:
f (x) f (a) +

f (x)


f (n) (a)
n=0

n!

(x a)n

(1)

(2)

where f (n) indicates the nth derivative of the function, and the exclamation mark
indicates the factorial. Conveniently, ex is its own derivative. Approximate e0.15
using the Taylor series and a while loop. Note that x = 0.15 is close to a convenient
known a value. Your allowable absolute error (error = |guess true|) is to be less
than or equal to 109 , and you must tell me how many terms in the Taylor series
were required to achieve convergence. (Suggest using disp)

1.2

(10pts) for Loops

The Fibonacci series is dened by creating the next term in the series as the sum
of the two prior. For example, if we began with 0 and 1, we would go like: 0+1=1,
1+1=2, 1+2=3, 2+3=5, and so on. Taking 1 as the rst term, 1 as the second term,
etc., write a for loop to calculate the 50th term in this series.

MAE 215: Homework #7


Instructor: Mark Miner
Assigned February 1, 2013
Due 11:59am, February 6, 2013
Deliverables: Two pictures and one M-le, though the M-le is optional (but
its what I use to assign partial credit if your gures are not perfect). As always,
name your M-le as asuid hw7.m.

Problem 1

Critical Heat Flux

This assignment requires you to use the hw7 data.mat le, available on the HW
assignment page. To load the data in the le into MATLAB, simply save the le to
your working directory (something like Documents/MATLAB/MAE215, hopefully),
and then in your code type load hw7 data.mat.
In the MAT-le, temperature data are split into two matrices, TTC hw carrying heated-surface thermocouple data and Tref hw carrying refrigerant temperature
data. The ve columns of TTC hw are to be labeled B, C, D, F, and G, respectively.
The two columns of Tref hw are to be labeled Inlet and Outlet, respectively. Pressure data are carried in the two-column matrix p hw, and are to be labeled Inlet and
Outlet, respectively. Time is carried in the single-column matrix t.

1.1

(10 pts) Surface Temperatures

Plot the time-temperature curves for all of the thermocouples in TTC hw. Provide
descriptive axis captions, a legend and a title. If possible, print your gure to PDF
for submission. Otherwise, saving as a JPG is acceptable.

1.2

(10 pts) Inlet and Outlet States

Using subplot, display both inlet and outlet pressure vs. time on one subplot. In
the same gure, make a second subplot and display the inlet and outlet refrigerant
temperatures. For both subplots, provide descriptive axis captions (indicating which
axis belongs to which data), and provide legends and a title. If possible, print your
gure to PDF for submission. Otherwise, saving as a JPG is acceptable.

.........

MAE 215: Homework #8


Instructor: Mark Miner
Assigned February 6, 2013
Due 11:59am, February 8, 2013
Deliverables: One M-le that executes the required data inprocessing and outputs the required values and plot.

Problem 1

Reading and Reckoning

This assignment requires you to use the hw8 data.csv le, available on the HW
assignment page.

1.1

(5 pts) Incoming

Using an appropriate command-line data reading function, have your M-le place the
contents of hw8 data.csv into the appropriate workspace of your M-le. Import
the columns of Time (s), Angle (rad), and Speed (m/s).

1.2

(15 pts) The Blind Navigator

The data for time, angle, and speed are uniform random values, with directions
splattered around the compass. Working from dead reckoning, and assuming an initial
position of (0, 0), determine the mean x-displacement, the mean y-displacement, and
plot the course taken.

.........

MAE 215: Homework #9


Instructor: Mark Miner
Assigned February 8, 2013
Due 11:59am, February 13, 2013
Deliverables: Two JPG les, one text le, and an M-le.
This assignment requires you to use the hw9 original armstrong.jpg le,
available on the HW assignment page. You must submit your M-le, as you are
required to perform the operations detailed below in the code.

Problem 1

In Memoriam: Neil Armstrong

On August 25th of 2012, America lost Neil Armstrong. He was the rst man on the
moon, a test pilot, naval aviator, professor, aeronautical engineer, and American hero.
On July 20, 1969, he and Buzz Aldrin walked on the moon, while Michael Collins orbited in the Command-Service Module. The le hw9 original armstrong.jpg
contains a photo of Neil taken by Buzz Aldrin on their way back to Earth. Like many
old images, its colors are somewhat distorted. It is a JPG, so it comes in RGB format.

1.1

(10 pts) Corrections and Amplications

Import the picture and apply the following restorative tweaks:


Increase the red content by 5%
Decrease the green content by 5%
Decrease the blue content by 20%
Write the corrected image to disk (using imwrite) and submit your resulting
JPG.
Photo courtesy of NASA Apollo Archive; Apollo Image Gallery; Author: NASA /
Edwin E.Buzz Aldrin, Jr.

1.2

(10 pts) Fade to Black

Using the corrected image you obtained in part one, reduce it to black-and-white,
write the resulting image to disk (using imwrite) and submit your resulting JPG.

1.3

(10 pts) By the Numbers

Using the reduced (m x n x 1) image you obtained in 1.2, write a tab-delimited


ASCII text le (.txt extension, i.e., asuid hw9 data.txt) containing the numerical
array representing the image. No headers are necessary. Submit the resulting text
document.

.........

MAE 215: Homework #10


Instructor: Mark Miner
Assigned February 13, 2013
Due 11:59am, February 15, 2013
Deliverables: Submit one M-le.

Problem 1

(10 pts) Cells

Cell arrays are indexed general-purpose buckets. Create an M-le which puts the
following objects into one cell array:
1) A 100x100 magic square (use magic)
2) The string The 10th homework
3) A vector from 1 to 1000, spaced with increments of 0.1
4) The square of the vector dened in (3)
5) A structure array made by assigning an output while loading the MAT le from
Homework 7.
Next, call items 3 and 4 back from the cell array and plot them with vector (3)
on the x-axis, and vector (4) on the y-axis. No labels or legend are necessary.

.........
Problem 2

(10 pts) Structures

Structure arrays are named-eld general-purpose buckets. Create an M-le which


puts the following objects into one structure:
1)
2)
3)
4)
5)

A 100x100 random array (use rand)


The string The 10th homework
A vector from -1000 to 0, spaced with increments of 0.1
The square of the vector dened in (3)
The cell array made in Problem 1.

Next, call items 3 and 4 back from the cell array and plot them with vector (3)
on the x-axis, and vector (4) on the y-axis. No labels or legend are necessary.

.........

MAE 215: Homework #11


Instructor: Mark Miner
Assigned February 15, 2013
Due 11:59am, February 20, 2013
Deliverables: Submit one M-le, which outputs the desired image.
Required: Data le hw11 dPm.txt from BlackBoard.

Problem 1

(25 pts) Microchannel Pressure Drop

Boiling refrigerant in very small channels is an eective way to rapidly remove large
amounts of heat. Such devices are called microchannel evaporators. Large pressure
drops pose a signicant problem to the application of this technology, because small
channels have large resistance to ow (see Poiseulles Law for the basic idea, but it
scales as 1/D4 ).
A recent improvement in the eld of microchannel evaporators is the idea of
expanding the channel cross-section in the ow direction, letting the channel get
bigger as more refrigerant boils away to vapor. This improvement is optimizable for
maximum heat rejection, and seems to substantially and monotonically reduce the
pressure drop in such devices.
In this assignment, you will produce four linear ts to the four sets of data supplied
in the le hw11 dPm.txt. The le is comma-delimited, and has eight columns of
data; the odd columns are mass ow rates (g/s), the even are pressure drops (kPa).
The data come from the four microchannel evaporators employed to ascertain the
existence of an optimum expansion. They have progressively larger expansion angles,
and the nominal angle (in degrees) is noted in the column headers. Mass ow rate is
the independent (x-axis) variable.
On one gure, plot the four sets of data along with the MATLAB-derived linear
t of each (do not use plotyy). Label your axes, add a legend with four entries
identifying the nominal expansion rate, and title the gure Microchannel Pressure
Drop. Be sure to use dierent colors and tick-marks for the data sets, and make the
t lines the same color as the corresponding data set.
Note: - The zero- and half-degree expansions have one fewer data point than the
one- and two-degree. Do not include the resulting 0, 0 points in your t. You will see
what I mean when you import the data.

.........

MAE 215: Homework #12


Instructor: Mark Miner
Assigned February 20, 2013
Due 11:59am, February 22, 2013
Deliverables: Submit one M-le, which plots and displays output as required.

Problem 1
1.1

(10 pts) The Syms

(5pts) Circles

Using the MATLAB symbolic environment, dene a parametric circle, as:


y = cos(t), x = sin(t)

(1)

and plot it for t = [, ].

1.2

(5pts) Integration

Evaluate the following symbolically in MATLAB, and be sure the results display
in the command window:
 100
dx
(2)
F =
x + x ln(x)
1


d
2
ln(cosh(x ))
G=
(3)
dx
 
 a
x
H=
dx
(4)
3 sinh
3
0

.........
Problem 2

(5pts) Structures and Cells

Create a cell array containing your symbolic objects F , G, and H from 1.2 above,
and create a structure containing the x and y objects from 1.1. Display both of these
objects in the command window.

.........

You might also like