Uploaded by Shruti Diwase

MatLab Sheet-1

advertisement
MATLAB – Lab Sheet 1
1. Use MATLAB to compute the roots of the following polynomials:
a. 𝑝(π‘₯) = π‘₯ 3 + 8π‘₯ 2 + 10π‘₯ + 4
b. 𝑝(𝑦) = 𝑦 5 + 7𝑦 4 + 19𝑦 3 + 25𝑦 2 + 16𝑦 + 4
2. Use MATLAB to derive the polynomials having the following roots:
a. −6.5708
− 0.7146 + 𝑗0.3132
− 0.7146 − 𝑗0.3132
b. Two roots at and three roots at π‘₯ = −2.000 and three roots at π‘₯ = −3.000
3. Use MATLAB to evaluate the polynomials below at the specified values.
a. 𝑝(π‘₯) = π‘₯ 3 + 8π‘₯ 2 + 10π‘₯ + 4 π‘Žπ‘‘ π‘₯ = 1.25
b. 𝑝(𝑦) = 𝑦 5 + 7𝑦 4 + 19𝑦 3 + 25𝑦 2 + 16𝑦 + 4 π‘Žπ‘‘ 𝑦 = −3.75
4. Define the variables π‘₯ and 𝑧 as π‘₯ = 5.3, and 𝑧 = 7.8, then evaluate:
π‘₯𝑧
2
𝑧)
(a) (π‘₯⁄
+ 14π‘₯ 2 − 0.8𝑧 2
π‘₯ 2
𝑧
𝑧
π‘₯
1⁄
2
(b) π‘₯ 2 𝑧 − 𝑧 2 π‘₯ + ( ) − ( )
5. Define two variables: alpha= 35°, beta= 23°. Using these variables, show that the following
trigonometric identity is correct by calculating the value of the left and right sides of the equation:
1
π‘π‘œπ‘ π›Όπ‘π‘œπ‘ π›½ = [cos(𝛼 − 𝛽) + cos (𝛼 + 𝛽)]
2
6. Two trigonometric identities are given by:
(a) π‘‘π‘Žπ‘›4π‘₯ =
π‘₯
(b) π‘‘π‘Žπ‘› 2 =
4π‘‘π‘Žπ‘›π‘₯−4π‘‘π‘Žπ‘›3 π‘₯
1−6π‘‘π‘Žπ‘›2 π‘₯+π‘‘π‘Žπ‘›4 π‘₯
1−π‘π‘œπ‘ π‘₯
𝑠𝑖𝑛π‘₯
For each part, verify that the identity is correct by calculating the values of the left and right sides of
the equation, substituting π‘₯ = 17°.
7. Create a row vector with 15 equally spaced elements in which the first element is 9 and the last
element is 44.
8. Create a column vector in which the first element is 14, the elements decrease with increments
of-3, and the last element is -10. (A column vector can be created by the transpose of a row vector.)
9. Create the matrix shown by using the vector notation for creating vectors with constant spacing
when entering the rows (i.e., do not type individual elements).
A=
2.5000
42.0000
15.0000
3.0000
3.5000
38.6000
14.6000
2.0000
4.5000
35.2000
14.2000
1.0000
5.5000
31.8000
13.8000
0
6.5000
28.4000
13.4000
-1.0000
7.5000
25.0000
13.0000
-2.0000
10. Create the matrix A in Problem 9, and then use colons to address a range of elements to create
the following vectors:
(a) Create a four-element row vector named Va that contains the third through sixth elements of the
second row of A.
(b) Create a three-element column vector named Vb that contains the second through fourth
elements of the fifth column of A.
11. Create the matrix A in Problem 9, and then use colons to address a range of elements to create
the following matrices:
(a) Create a 3 x 4 matrix B from the first, second, and fourth rows, and the first, second, fourth, and
sixth columns of the matrix A.
(b) Create a 2 x 3 matrix C from the second and fourth rows, and the second, fifth, and sixth columns
of the matrix A.
12. For the function 𝑦 =
(2π‘₯ 2 −16π‘₯+4)2
,
π‘₯+15
calculate the value of y for the following values of π‘₯ =
−1.2, −0.4, 0.4, 1.2, 2, 2.8, 3.6. Solve the problem by first creating a vector π‘₯, and then creating a
vector 𝑦, using element-by-element calculations. Make a plot of the points using asterisk markers for
the points and a black line connecting the points. Label the axes.
13. Define π‘Ž and 𝑏 as scalars π‘Ž = 3 π‘Žπ‘›π‘‘ 𝑏 = −4, π‘₯ = [−3, −2.8, −2.6, … , 1.6, 1.8, 2]. Then use
these variables to calculate 𝑦 by:
π‘Ž 2 ⁄𝑏 3
𝑦=8 2
π‘₯ + 𝑏 2 ⁄π‘Ž 3
Plot 𝑦 𝑣𝑠 π‘₯.
(𝑑+3)2
14. For the function 𝑦 = 6𝑑 (1/3) − 2(𝑑+4) + 2, calculate the value of 𝑦 for the following values of 𝑑:
0, 2, 4, 6, 8, 10, 12, 14, 16, using element-by-element operations.
𝑛
15. Use MATLAB to show that the sum of the infinite series ∑∞
𝑛=0(−1)
1
converges
(2𝑛+1)
to πœ‹/4 . Do
it by computing the sum for:
(a) n = 100
(b) n = 1,000
(c) n = 5,000
In each part create a vector n in which the first element is 0, the increment is 1, and the last term is
either 100, 1,000, or 5,000. Then, use element-by-element calculation to create a vector in which the
elements are (−1)𝑛
1
(2𝑛+1)
. Finally, use the function π‘ π‘’π‘š to add the terms of the series. Compare
the values obtained in parts a, b, and c with the value of πœ‹/4. (Do not forget to type semicolons at
the end of commands that otherwise will display large vectors.)
Download