0% found this document useful (0 votes)
1 views

Assignmet3

Uploaded by

srsisodia1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Assignmet3

Uploaded by

srsisodia1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 3: Matlab

Course Instructor:Dr. Sudeep Kundu


Department of Mathematical Sciences
Rajiv Gandhi Institute of Petroleum Technology Jais Amethi

1. Use the dot function to find the dot product of the following vectors:

− →

(a) A = [31, 2, 3, 44] and B = [12, 20, 15, 74]

− →
− →
− →

(b) Find the dot product of A and B by summing the array products of A and B .
2. Consider the following matrix A = [1, 2, 3; 2, 4, 6; 3, 6, 9]. Would you expect it to be singular or not? If it non-singular
find the inverse of matrix A.
3. Consider the following system of three equations with three unknowns:

x+y+z+w = 10
2x + 3y + z + 5w = 31
(a)
−x + y − 5z + 3w = −2
3x + y + 7z − 2w = 18.
3x + 2y − z = 10
2x + 3y + z = 31
(b)
−x + 3y + 2z = −2
x − y − 7z = 18.
Find the solution of the system.
4. Solve the following systems using left division:
3x + 2y + 5z = 22
2x + 3y − 2z = 8
(a)
x+y+z = 6
2x − 4y − 7z = −27.
3x + 2y + 5z = 22
(b)
4x + 5y − 2z = 8.
5. Compute the matrix product A*B of the following pairs of matrices:
(a) A = [12, 4; 3, −5] and B = [2, 12; 0, 0].
(b) A = [1, 2, 3; 2, 4, 6] and B = [−2, 4; 3, 8; 12, 2].
Show that A ∗ B is not the same as B ∗ A.
6. Solve the following systems of equations, using both matrix left division and the inverse matrix method:
(a) −2x + y = 3, x + y = 10.
5x + 3y − z = 10
(b) 3x + 2y + z = 4
4x − y + 3z = 12.
3x + 2y + 5z + w = 24
x − 3y + 7z + w = 12
(c)
2x + 2y − 3z + 4w = 17
x+y+z+w = 0.
7. In general, matrix left division is faster and more accurate than the matrix inverse. Using both techniques, solve the
above system of equations and time the execution with the tic and toc functions.
8. The future-value-of-money formula relates how much a current investment will be worth in the future, assuming a constant
interest rate.
F V = P V ∗ (1 + I)n ,
where FV is the future value, PV is the present value or investment, I is the interest rate expressed as a fractional amount
per, compounding period-i.e., 5% is expressed as .05, n is the number of compounding periods.
(a) Create a MATLAB function called future value with three inputs: the investment (present value), the interest rate
expressed as a fraction, and the number of compounding periods.
(b) Use your function to determine the value of a $1000 investment in 10 years, assuming the interest rate is 0.5% per
month, and the interest is compounded monthly.
9. This problem requires you to generate temperature-conversion tables. Use the following equations, which describe the
relationships between temperatures in degrees Fahrenheit (TF ), degrees Celsius TC , kelvins (TK ), and degrees Rankine
(TR ), respectively:

TF = TR − 459.67◦ R
TF = 9/5TC + 32◦ F,
TR = 9/5TK
Create the primary function should be named as temperature conversions and should include the subfunctions F to K,
C to R, C to F.
Within the primary function use the subfunctions to:
(a) Generate a conversion table for values from 0◦ F to 200◦ F . Include a column for temperature in Fahrenheit and
Kelvin.
(b) Generate a conversion table from 0◦ C to 100◦ C. Print 25 lines in the table. (Use the linspace function to create your
input vector.) Your table should include a column for temperature in Celsius and Rankine.
(c) Generate a conversion table from 0◦ C to 0◦ C. Choose an appropriate spacing. Include a column for temperature in
Celsius and Fahrenheit.

10. A rocket is launched vertically. At time t = 0, the rocket’s engine shuts down. At that time, the rocket has reached an
altitude of 500 m and is rising at a velocity of 125 m/s. Gravity then takes over. The height of the rocket as a function
of time is
f (t) = −4.9t2 + 100t + 250 t > 0
(a) Create a function called height that accepts time as an input and returns the height of the rocket. Use your function
in your solutions to parts b and c.
(b) Find the time when the rocket starts to fall back to the ground. (The max function will be helpful in this exercise.)
11. (a) Create an anonymous function called my function, equal to

−x5 − 5x3 − 3x2 + 3 + ex

(b) Use the fminbnd function to find the minimum function value in this range. The fminbnd function is an example
of a function function, since it requires a function or function handle as input. The syntax is fminbnd(function handle,
xmin, xmax).
Three inputs are required: the function handle, the minimum value of x, and the maximum value of x.
The function searches between the minimum value of x and the maximum value of x for the point where the function
value is a minimum.

You might also like