0% found this document useful (0 votes)
29 views4 pages

Assignment 1, AH, Winter 2025

This document outlines Homework Set #1 for BCEE 231, covering chapters 1 to 4 and due on February 10th. It includes ten questions that require the creation of scripts and functions to solve problems related to special relativity, matrix operations, projectile motion, heat exchange, plotting functions, GPA calculation, Cartesian to polar conversion, and pH classification. Each question has equal marks and emphasizes the application of programming skills in various scientific contexts.

Uploaded by

emilio-saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

Assignment 1, AH, Winter 2025

This document outlines Homework Set #1 for BCEE 231, covering chapters 1 to 4 and due on February 10th. It includes ten questions that require the creation of scripts and functions to solve problems related to special relativity, matrix operations, projectile motion, heat exchange, plotting functions, GPA calculation, Cartesian to polar conversion, and pH classification. Each question has equal marks and emphasizes the application of programming skills in various scientific contexts.

Uploaded by

emilio-saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BCEE 231– Homework Set #1 (worth 5%)

Chapters 1, 2, 3, and 4
Due date: Monday Feb 10th

Check the course outline for the procedure of submission


------------------------------------------------------------
Note: Questions have equal marks

Question 1:
According to special relativity, a rod of length L moving at velocity v will shorten by
an amount δ, given by:

where c is the speed of light (about 300×106 m/s). Create a script and define
appropriate variables (like L, c, v). Write a variable δ based on the variables you
defined before. Then, calculate how much a rod 2 meter long will contract when
traveling at 5,000 m/s.

Question 2:
Create the following matrix by using vector notation for creating vectors with constant
spacing and/or the linspace command. Do not type individual elements explicitly.

Question 3:
Define p and w as scalars: p=2.5 and w=5.7. Define t, x, y as vectors: t=[1 2 3 4
5], x=[2.5 3.1 4.2 1.9 5.5] and y=[10 21 14 7 3]. Use these variables to calculate
the following expressions using element-by-element calculations for the vectors.

Question 4:

1
The position as a function of time (x(t),y(t)) of a projectile fired with a speed of v0 at
an angle α is given by

where g = 9.81 m/s2. The polar coordinates of


the projectile at time t are (r(t),θ(t)), where

Consider the case where v0=160 m/s and θ=60°. Write a script that determines r(t)
and θ(t) for t=1, 5, 9, …,33s and displays the results in a three-column table where
the values of t, r, and θ are displayed in the first, second, and third columns,
respectively.

Question 5:
Create a random 3 x 5 matrix. Perform each of the following:

• Find the maximum value in each column.


• Find the maximum value in each row.
• Find the maximum value in the entire matrix.
• Find the cumulative maxima.

Question 6:
The net heat exchange by radiation from plate 1 with
radius b to plate 2 with radius a that are separated by
distance c is given by:

where T1 and T2 are the absolute temperatures of the


plates.

is the Stefan-Boltzman constant, and F1-2 is a shape factor


which, for the arrangement in the figure, is given by:

where X=a/c and, Y=c/b, and Z=1+(1+X2)Y2.

2
Write a script file that calculates the heat exchange q. For input the program asks
the user to enter values for T1, T2, a, b, and c. For output, the program prints a
summary of the geometry and temperatures and then prints the value of q.
As an example, use your script to calculate the results for T1=400K, T2=600K, a=1m,
b=2m, and c=0.1, 1, and 10m and displays the results as follows:

Question 7:
Write a script to plot the function f(x) = sin2(x)cos(2x) and its derivative, both on
the same plot, for 0 ≤ x ≤ 2π. Plot f(x) with a solid line, and f’(x) with a dashed line
with different colors. Add a legend and label the axes.
Hint: use linspace to create a vector of x values then feed that vector, separately, to
your f(x) and f’(x) to create y values.

Question 8:
Write a user-defined function that calculates grade point average (GPA) on a scale
of 0 to 4, where A = 4, A- = 3.7, B+ = 3.3, B = 3, B- = 2.7, C+ = 2.3, C = 2, C- =
1.7, D+ = 1.3, D = 1, and E = 0.
For the function name and arguments, use av = GPA (g,h). The input argument g is
a vector whose elements are the numerical values of the grades. The input argument
h is a vector with the corresponding credit hours. The output argument av is the
calculated GPA.
Use your function (i.e., call your function) to calculate the GPA for a student with the
following record:

Question 9:
Write a user-defined function that determines the polar y coordinates of a point
from the Cartesian coordinates in a two-dimensional plane.
For the function name and arguments, use [th rad] =CartToPolar (x, y). The input
arguments are the x and y coordinates of the point, and the output arguments are
the angle θ and the radial distance to the point. The angle θ is in degrees and is
measured relative to the positive x axis, such that it is a positive number in quadrants
I and II, and a negative number in quadrant III and IV.

3
Call your function to determine the polar coordinates of points (14, 9), (-11, -20),
and (-15, 4).

Cartesian to Polar → x = radial distance * cos(θ) radial distance 2


= x2 + y2

Hint: You need to use if-statement as part of your function to find θ.

Question 10:
In chemistry, the pH of an aqueous solution is a measure of its acidity. The pH scale
ranges from 0 to 14, inclusive. A solution with a pH of 7 is said to be neutral, a
solution with a pH greater than 7 is basic, and a solution with a pH less than 7 is
acidic. Write a script that will prompt the user for the pH of a solution, and will print
whether it is neutral, basic, or acidic. If the user enters an invalid pH, an error
message will be printed.

You might also like