$35
Please read the file, “How to complete and upload the solution template” before you begin. Download template_assign2.m and fill it in and then upload the completed file on D2L drop box. Also download test_assign2.m and assign2_solutions.mat to test your answers as you go. Make sure your name and UCID are correctly filled out.
The questions are based on content from chapter 3 of the textbook “MATLAB, An introduction with applications”.
Note the variable Q will not usually be assigned in your function call; just use the return variable ‘answer =’
Notation in this assignment assumes:
X =[x x1 2, ,...,xN], Y =[y y1, 2,..., yN], T =[t t1 2, ,...,tN], and 𝑍 = [𝑧%, 𝑧’, … , 𝑧)] are row vectors of samples.
Use MATLAB to calculate the following problems.
1. Given a vector of samples 𝑋 = [−100, −99, … ,99,100], create a vector 𝑌 calculated based on element-‐‑by-‐‑element operations such that 𝑦2 = 0.001 𝑥2’ + 1. Construct matrix 𝑄 such that
𝑋
𝑄 = 𝑌
𝑋 + 𝑌
2. The electric field intensity, 𝐸(𝑥), due to a ring of radius 𝑅 at any point 𝑥 along the axis of the ring is given by:
𝐸 𝑥 = 9604.5
Given R=6 cm and a row vector 𝑋 from elements ranging from 2 cm to 6 cm and spacing of
0.01 cm, use element-‐‑by-‐‑element operations to calculate a row vector 𝑌 whose elements are 𝑦2 = 𝐸(𝑥2). Then construct a matrix of
𝑄 = 𝑋
𝑌
Hint: use ‘format longg’ to see the significant digits (otherwise you’ll just see 0.0000)
3. The voltage 𝑉(𝑡) in Volt and the current 𝑖(𝑡) in Amp 𝑡 seconds after closing the switch in an RC circuit are given by F
𝑉 𝑡 1 − 𝑒EGH
F
𝑒EGH
given 𝑅 = 3800 Ω and 𝐶 = 4000×10EN F. Create a row vector 𝑇, with values of times from 0 to 20 sec with spacing of 2 sec, and use it to create row vectors 𝑋 and 𝑌 such that 𝑥2 = 𝑉(𝑡2) and 𝑦2 = 𝐼(𝑡2). Then construct a matrix of
𝑇
𝑄 = 𝑋
𝑌
4. Two vectors are given as
𝐮 = −1𝐢 + 2.5𝐣 + 0.5𝐤
𝐯 = +1𝐢 + 0.2𝐣 + 2𝐤
Compute the dot product as 𝑄 = 𝐮 ⋅ 𝐯.
5. Use cross() to compute the vector cross product as 𝑄 = 𝐮×𝐯, where 𝑄 is a row vector and 𝐮 and v are two row vectors defined in question 4.
6. Use Matlab to show that the reciprocals of square numbers produce a convergent series
W 1 𝜋’
’ = 6
𝑛
XY%
Do this by computing the following sums
%[ \[ %[[
1
𝑋 = , 𝑌 = 𝑛’ , 𝑍 =
XY% XY% XY%
and placing your answers in matrix 𝑄 = 𝑋 𝑌 𝑍
7. Given two matrices
−1 1 −1
and 𝐵 =
3 8 3
1 −1 1 10 2 0
𝐴 =
1 −1 1 1 3 12
Determine 𝑄 = 𝐴𝐵𝐵_ where the superscript denotes transpose
8. Given two matrices
1 −3 50 −2 1
𝐴 =2 2 4 and 𝐵 =5 1 −6
−2 0 62 7 −1
Determine 𝑄 = 𝐴E%(𝐴 + 𝐵𝐴_)
1 −3 5
9. Given matrix 𝐴 =2 2 4
−2 5 6
Let 𝐵 be the matrix formed by having each element of A inverted such that 𝐵 2,a = 1/ 𝐴 2,a Then calculate 𝑄 = 𝐴𝐵.
10. The following linear set of equations are determined by applying mesh current analysis to a circuit. Solve the linear set of equations using the \ operator in Matlab
−44𝑖% + 10𝑖’ + 16𝑖c = −20
10𝑖% − 43𝑖’ + 6𝑖c + 12𝑖d = 0
16𝑖% + 6𝑖’ − 30𝑖c + 8𝑖d = 12
12𝑖’ + 8𝑖c − 34𝑖d = −40
Let 𝑄 = [𝑖% 𝑖’ 𝑖c 𝑖d] be a row vector of the results.