Uploaded by arab valo

MATLAB & Excel Quiz: Numerical Computation & Plotting

advertisement
BE 1500 – Quiz 2 [100 points]
Submit this assignment as a PDF to the link on Canvas
Copy and paste your MATLAB commands and answers for each problem into a word document. For each
Matlab problem create a script file. For excel portions, copy the contents of any calculated cells into the
document with the cell reference also include a screen shot of the excel file. Save the word document as
a PDF. Submit the PDF and a zip file containing your script files and your excel files.
1- [20 pts] Create the variables V, N, and M in MATLAB as follows:
a) Create the row vector V using the linspace function or the colon operator. V should
consist of all the one-digit numbers that are divisible by 2, in ascending order.
b) Create the 2x4 matrix M using one of the vertcat or horzcat functions. The first
row of M should contain the values 0.5V and the second row of M should contain
the values V.
c) Create the 4x2 matrix N using one of the vertcat or horzcat functions. The first
column of N should contain the values V and the second column of N should
contain the values 2V + 5.
2- [20 pts] The conversion formula from Kelvin (°K) to Celsius (°C) is as follows:
[°๐ถ] = [°๐พ] − 273.15
Write a script that:
๏‚ท Asks the user their name
๏‚ท Asks the user the current temperature in Celsius (°C)
๏‚ท Converts the temperature to Kelvin (°K)
๏‚ท Prints the results using fprintf in the following format:
“Hello John! 26.85C is equivalent to 300.00K”
(This is just an example. Your output should depend on the user inputs. “John”
and “26.85” were example inputs in this case.)
Your numbers should have a precision of two digits after the decimal while
printing.
3- [20 pts] Create the following vector X, calculate the vector Y, and plot a graph of your
results (Y vs. X). Give your graph labels and a title.
X = [0 2 4 6 8 10]
Y = X^2 + 1.5*X - 3
4- [20 pts] Create a mesh plot for the following equation where d = 0 to 8π with
increments of 1.
x = sin(d)
y = cos(d)
Z=X+Y
Keep in mind that you need to use meshgrid before you calculate Z. Label each axis
and give a title to the whole graph.
5- [20 pts] Write a MATLAB script and use and if/else statement to calculate f(t):
2๐‘ก,
๐‘–๐‘“ 0 ≤ ๐‘ก < 0.5
๐‘–๐‘“ ๐‘ก = 0.5
๐‘“(๐‘ก) = { 4,
2
๐‘ก + 2, ๐‘“๐‘œ๐‘Ÿ ๐‘Ž๐‘™๐‘™ ๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ ๐‘ก
Test your code with different values of t.
Download