 # assignment using Matlab Anonymous
timer Asked: Oct 16th, 2018
account_balance_wallet \$9.99

### Question Description

I uploaded the assignment. there are 7 parts using Matlab program.

Part I: File Directory

Part II: MATLAB commands/functions and matrix manipulations

Part III: Plotting cosine curve

Part IV: Calculating the average molar mass on Mars.

Part V: Normal Distribution

Part VI: Statistics Measures and plotting

Part VII: Statistics Measures and Plotting

### Unformatted Attachment Preview

GEOG 444 Midterm: Due @ 12pm noon on Tuesday, October 16th, 2018 Name: _______________________ Part I: File Directory Use the image below of the directory structure and write down your answer after each question after the provided prompt “>>”. (1 pt each) C:\ Midwest Iowa Kansas Nebraska Columbia South Northeast Missouri StLouis UMKC West Oregon LosAngeles KansasCity Rockhurst California DeVry UCLA SanFrancisco USC 1) Assume you are currently in the root directory C:\. What is the MATLAB command to go to the directory called “Kansas” using a relative path? >> 2) Assume you are in the “Midwest” folder. Write the command to change directories to “UMKC” directory. a) relative path: >> b) absolute path: >> 3) Assume you are in the “UMKC” folder. Write the command to change directories to “UCLA” directory. a) relative path: >> 1 GEOG 444 Midterm: b) absolute path: >> 4) What command will output your current working directory? >> 5) What command will display the contents of the current directory? >> 6) What command will display all the files with extension .mat ? >> Part II: MATLAB commands/functions and matrix manipulations (1 pt each) Find out the MATLAB commands to do the following operations. 1) Round a number X towards nearest integer. Assume X = –3.14, write down the answer. >> >> 2) Round a number X to the nearest integer towards plus infinity. Assume X = –3.14, write down the answer after you apply the command. >> >> 3) Round a number X to the nearest integer towards minus infinity. Assume X = –3.14, write down the answer after you apply the command. >> >> 4) Find out the MATLAB command to generate a random integer between –9 and 2. >> 5) Find out the MATLAB command to calculate the absolute value of a number x= –2.7183, write down the answer after you apply the command. >> >> 6) Find out the MATLAB command to calculate magnitude of 3-dimensional vector x = [–2 –3 4], write down the answer after you apply the command. >> >> 2 GEOG 444 Midterm: 7) Find out the MATLAB codes (2 methods) that makes a column vector called “vector1” that holds all odd numbers from 1 to 21. Method #1: >> Method #2: >> 8) Subtraction of two vectors: vector x1= [–3 1], and vector, x2= [1 –2], a) draw the subtraction of x1 – x2 in x-y coordinates b) MATLAB code to the subtraction of the two vectors, and write down the result in 2nd line. >> >> 9) MATLAB command to get the a) size of a matrix >> b) length of a vector >> c) number of elements in a matrix >> 3 GEOG 444 Midterm: 10) Assume there is a matrix named X: 2 4 10 3 −5 6 𝑋=# 0 7 9 6 −1 11 8 What is the MATLAB command to get a new matrix X2 = 1 >> 9 6 2 from X? 11 8 11) Assume there is a matrix named X: 𝑋=1 5 4 3 2 −6 − 5 − 4 5 What is the MATLAB command to get a new matrix X2 = 34 3 >> −6 − 54 from X? −4 𝟓𝟓𝟓 ⎡𝟓 𝟓 𝟓⎤ ⎢ ⎥ 12) What is the command to generate a matrix X = ⎢𝟓 𝟓 𝟓⎥ ⎢𝟓 𝟓 𝟓⎥ ⎣𝟓 𝟓 𝟓⎦ >> 4 2 9 3 –4 –2 13) List all the elements in order from matrix 𝑋 = # 0 (this question is to test you 1 4 5 – 8 10 8 understand the ordering of all the matrix elements) Your answer: 3 4 6 8 Assume there are two matrices: mat1 = 1 2 and mat2 = 1 2, write down the new –6 –5 –2 –1 matrix of newMat1 = [mat1; mat2] and newmat2 =[mat1, mat2] newmat1 = newmat2 = 4 GEOG 444 Midterm: Part III: Plotting cosine curve (10 pts) Plot the cosine curve: y=cos(x), with independent variable, x, going from -3p ≤ x ≤ 3p and have 300 total data points. Plot it using plot command in black solid line, then highlight in the plot those points with x=–2p, – p, 0, p, 2p and corresponding y values using “stem” function in MATLAB. o The x-axis should be labeled “x values” o The y-axis should be labeled “y=cos(x)” o Title should be “My cosine curve” o The x-axis limit should be set from -3p to 3p and y-axis limit should be set from -1.2 to 1.2. o Draw one black solid vertical line to highlight the y-axis. o Add major grid lines to the current axes o Highlight x labels of -2pi, -pi, 0, pi, 2pi and denote the labels as –2p, –p, 0, p, and 2p 5 GEOG 444 Midterm: Part IV: Calculating the average molar mass on Mars. (10 pts) The Earth first started to form 4.6 billion years ago, and the first atmosphere was made mainly of hydrogen and helium. During the first billion years, these light gases quickly escaped the Earth's gravitational attraction and were replaced with carbon dioxide, nitrogen and water vapor from the large number of volcanoes that existed as the Earth started to cool. This pre-life atmosphere contained 90% carbon dioxide CO2, 5% nitrogen N2, 2% sulfur dioxide SO2, 2% hydrogen sulfide H2S and 1% water vapor H2O and other traces of gases. It was hot, smelly and deadly poisonous! Carbon dioxide, nitrogen, sulfur dioxide, hydrogen sulfide and water vapor have molar masses of 44 g/mol, 28 g/mol, 64 g/mol, 34 g/mol and 18 g/mol separately. 1) Please calculate the average molar mass (unit: g/mol) of the pre-life atmosphere. Have your MATLAB codes and answer. 2) And please plot the pie chart of the composition and denote each gas with its percentage correspondingly. Please write or attach your MATLAB codes. 6 GEOG 444 Midterm: Part V: Normal Distribution (10 pts) During the period of year 1975-2014, the annual-mean surface air temperature in Kansas City undergoes large year-to-year variability. The record shows that 99.7% of Kansas City annual-mean surface air temperatures are between 50.8 F and 59.8 F. Assuming this temperature distribution is nearly a normally distribution, please: 1) calculate the mean value and the variance of KC annual-mean surface air temperature. 2) calculate the corresponding annual-mean surface air temperatures with z-score equal to -2 and 2 separately. 7 GEOG 444 Midterm: Part VI: Statistics Measures and plotting – 1 (15 pts) 1) Download the MATLAB data file tempdata.mat from Canvas Modules Week07 directory and save it into your MATLAB working directory. It saves the annual-mean temperature (unit: F) of Missouri from year 1997 until year 2016. Column one is calendar year, and column two is the temperature for each year. Calculate the mean, maximum, minimum, range, average deviation, standard deviation, variance, skewness and kurtosis values. Find out the corresponding warmest and coldest years and name the years as yearwarmest and yearcoldest separately. mean= maximum= range= average deviation= standard deviation= variance= skewness= kurtosis= yearwarmest= yearcoldest= minimum= 2) Plot this temperature time series, with x-axis as year and y-axis as temperature. Attach the plot. In this plot, use the following formatting: o Use the plot command to plot the series with black color. o Set the axis scaling for x-axis from 1997 to 2016, y-axis from 50 to 60 F. o Draw a solid red horizontal line to present the 20-year mean. o Highlight the warmest and coldest year by putting two red diamonds on the plot. o The x-axis should be labeled “Year” o The y-axis should be labeled “Temperature (unit: F)” o Add major grid lines to the current axes o Title should be “Missouri annual-mean temperature (1997-2016)” Attach or write down your MATLAB codes. 8 GEOG 444 Midterm: Part VII: Statistics Measures and Plotting – 2 (15 pts) Download the MATLAB data file temp.mat from Canvas Modules Week07 directory and save it into your MATLAB working directory. It is monthly averaged air temperature of Missouri from January 1997 until December 2016. The order of data is arranged as from January 1997, February 1997, …, December 1997, January 1998, …, to December 2016. Total length is 240. 1) Plot this series of data, with x-axis showing the calendar year from 1997 to 2016. In x-axis, set x-ticks as the following years, 2000, 2005, 2010, and 2015. (3 pts) 2) First calculate the 20-year averaged monthly (Jan, …, Dec) climatology of temperature for each month. Then plot a bar chart to show the climatology value of temperature from January to December. (hint: to do this, you’ll need to reshape the data into a matrix, then calculate the mean for each month. You can always “help mean” in MATLAB) (5 pts) 3) Calculate the skewness of temperature for each month (hint: you need the “for” loop in MATLAB to calculate each month) and plot a stem plot to show the skewness values of each month from January to December. Which month’s distribution is closest to a normal distribution? Which month’s distribution show the longest tail? (7 pts) You need to write down or attach your MATLAB codes and attach your plots. 9 GEOG 444 Midterm: Extra Credits: Part VIII: Probability (you need to write down the formulas used and your answers) (3 pts) 1) What are the odds of pulling a Jack, a Queen and a King from a standard 52-card deck of cards with three draws? The order has to be first a Jack and then a Queen and then a King. (1 pt) 2) What are the odd of pulling an Ace or a diamond from a 52-card deck of cards with one draw? (1 pt) 3) What is probability of getting 2 tails in 5 successive coin tosses? (1 pt) 10 ...
Purchase answer to see full attachment

## Tutor Answer

Professor_Aldin
School: University of Maryland   Hi, is it okay if I request another 1 hour?
Attached.

GEOG 444 Midterm:
Due @ 12pm noon on Tuesday, October 16th, 2018

Name:

Part I: File Directory
Use the image below of the directory structure and write down your answer after each question after
the provided prompt “>>”. (1 pt each)
C:\

Midwest

Iowa

Kansas

Nebraska

Columbia

South

Northeast

Missouri

StLouis

UMKC

West

Oregon

LosAngeles

KansasCity

Rockhurst

California

DeVry

UCLA

SanFrancisco

USC

1) Assume you are currently in the root directory C:\. What is the MATLAB command to go
to the directory called “Kansas” using a relative path?
>>C:\Midwest\Kansas
2) Assume you are in the “Midwest” folder. Write the command to change directories to
“UMKC” directory.
a) relative path:
>> cd ./moves/down/a/UMKC
b) absolute path:
>> Midwest/Kansas/UMKC
3) Assume you are in the “UMKC” folder. Write the command to change directories to
“UCLA” directory.
a) relative path:
>>UMKC\UCLA

1

GEOG 444 Midterm:
b) absolute path:
>>cd\UMKC\move\UCLA
4) What command will output your current working directory?
>> /directory/newhomedirectory/
5) What command will display the contents of the current directory?
>>C:\Program Files\Matlab\myfiles
6) What command will display all the files with extension .mat ?
>>C:\Program Files\Matlab\R2018b\myfiles\display
Part II: MATLAB commands/functions and matrix manipulations (1 pt each)
Find out the MATLAB commands to do the following operations.
1) Round a number X towards nearest integer. Assume X = –3.14, write down the answer.
>> round(x) = int(0.1)

>> round (-3.14) = int (0.1) = -3
2) Round a number X to the nearest integer towards plus infinity. Assume X = –3.14, write down
the answer after you apply the command.
>> round(x) = int(x+0.1)

>> round (-3.14) = int (1.0) = -3
3) Round a number X to the nearest integer towards minus infinity. Assume X = –3.14, write down
the answer after you apply the command.
>> round(x) = int(x-0.1)

>>round(-3.14) = int (-0.1) = -3
4) Find out the MATLAB command to generate a random integer between –9 and 2.
>> B=randi([-9,2])
5) Find out the MATLAB command to calculate the absolute value of a number x= –2.7183, write
down the answer after you apply the command.
>> y = abs(x)
>> y = abs (-2.7183) = -2.7183
6) Find out the MATLAB command to calculate magnitude of 3-dimensional vector x = [–2 –3 4],
2

GEOG 444 Midterm:
write down the answer after you apply the command.
>> v = [-2 -3 4];
n = norm(v)
>>n = 5.385

3

GEOG 444 Midterm:
7) Find out the MATLAB codes (2 methods) that makes a column vector called “vector1” that holds
all odd numbers from 1 to 21.
Method #1:
>> j=1;
k=1;
for i=1:21
if mod(i,2)==0 && i~=1
else
odd(k)=i;
end
odd

Method #2:
>> x=1;
y=21;
v=x+1:y-1
v_odd=v(mod(v,2)~=0)

8) Subtraction of two vectors: vector x1= [–3 1], and vector, x2= [1 –2],
a) draw the subtraction of x1 – x2 in x-y coordinates

codes: for

i=1:length(x)-1
min=i;
for j=i+1:length(x)
if x(j)> X1 = [-3 1];
X2 = [2 -2];
Z = X1 - X2

>> Z = 1 x 2
-5 3
9) MATLAB command to get the
a) size of a matrix
>> clc
a=[-3 1; 2 -2]; // can be any matrix
[r c] = size(a); %determine size of input
m = ones(r,c); %preallocate r x c ...

flag Report DMCA  Review Anonymous
Thanks, good work Brown University

1271 Tutors California Institute of Technology

2131 Tutors Carnegie Mellon University

982 Tutors Columbia University

1256 Tutors Dartmouth University

2113 Tutors Emory University

2279 Tutors Harvard University

599 Tutors Massachusetts Institute of Technology

2319 Tutors New York University

1645 Tutors Notre Dam University

1911 Tutors Oklahoma University

2122 Tutors Pennsylvania State University

932 Tutors Princeton University

1211 Tutors Stanford University

983 Tutors University of California

1282 Tutors Oxford University

123 Tutors Yale University

2325 Tutors