Please answer all the questions in the photos.
Answer them all in one MatLab script (.m file)
plz write all the answer in one script in matlab (.m file) split each answer by %%%%%%%%%%%%%%%%%%%%%%
7. The perfect gas law relates the pressure p, absolute temperature T, mass m, and volume V
of a gas. It states that
PV = mRT
The constant R is the gas constant. The value of R for air is 286.7 (N.m)/(kg.K). Suppose
air is contained in a chamber at room temperature (20º =293K). Create a plot having three
curves of the gas pressure in N/m2 versus the container volume in V in m3 for 20 < V < 100.
The three curves correspond to the following masses of air in the container: m=1kg, m=3kg,
and m=7kg.
3. Use a for loop to plot the function given in problem 16 of the end-of-chapter 4 problems
over the interval -2 < x < 6. Properly label the plot. The variable y represents height in
kilometers, and variable x represents time in seconds.
4. Use a loop in Matlab to determine how long it takes to accumulate $1000000 in a bank
account if you deposit $10000 initially and $10000 at the end of each year; the account pays
6 percent annual interest.
I
5. a. Estimate the roots of the equation
πα
5T
23 – 3x2 + 5x sin
5
+3=0
4
4
by plotting the equation using an anonymous function.
b. Use the estimates found above to find the roots more accurately with the fzero function.
6. Plot columns 2 and 3 of the following matrix A versus column 1. The data in column 1 are
time(seconds). The data in columns 2 and 3 are force(newtons).
0
-7
6
5
--4
3
A=
-1
10
15
20
1
2
9
0
1
1. Rewrite the following statements to use only one if statement.
if x < y
if z < 10
**y*z
end
end
W =
2. Write a program that accepts a numerical value x from 0 to 100 as input and computes and
displays the corresponding letter grade given by the following table.
• A x > 90
. B 80 < x < 89
. C 70 < x < 79
• D 60 < x < 69
• F x < 60
a. Use nested if statements in your program (do not use elseif).
b. Use only elseif clauses in your program.
3. Use a for loop to plot the function given in problem 16 of the end-of-chapter 4 problems
over the interval -2 < x < 6. Properly label the plot. The variable y represents height in
kilometers, and variable x represents time in seconds,