- May 15, 2020

ENG104 MATLAB AssignmentDue 5pm 4/10/191. Consider the RL circuit shown in Figure 1.(a) [1 mark] Determine an ODE for the current i flowing through the inductor.(b) [1 marks] Approximate the derivative asdidt∼= i(t+ δt)− i(t)δtto get a recursive equation for i(t+ δt) in terms of i(t).(c) [2 marks] Write a MATLAB script RLPlotter1c that uses the result of 1(b) to compute and ploti for t ∈ [0, T ]. Use values of R = 1 Ω, L = 2 H, T = 10 s, Vs = 10 V, i(0) = 0 A, and δt = 0.1 s.Ensure that the axis labels are labeled.(d) [2 marks] Write a MALTAB function RLSolver that takes six inputs and returns two outputs.The inputs should be the values of R, L, T , Vs, i(0), and δt. The first output should be a vectorcontaining the values of t and the second output should be a vector containing the correspondingvalues of i(t). (You should be able to reuse code from the previous question for this).(e) [2 marks] Write a MATLAB script RLPlotter1e that makes use of RLSolver to produce a plotshowing i(t) for δt = 0.01 s, δt = 0.1 s, and δt = 1 s (all other parameters are as given in 1(c)).Ensure the plot contains axis labels as well as a legend.(f) [2 marks] Write a MATLAB script RLPlotter1f that makes use of RLSolver to produce a plotshowing i(t) for all four possible combinations of R = 1 Ω or R = 2 Ω and L = 1 H or L = 2 H (allother parameters are as given in 1(c)). Ensure the plot contains axis labels as well as a legend.−+VsRiLFigure 1: RL circuit.12. Now consider the RLC circuit shown in Figure 2.(a) [2 marks] Determine an ODE for the current i flowing through the inductor.(b) [1 marks] Make the substitution ψ(t) = didt to convert the second order ODE into a pair of singleorder ODEs.(c) [2 marks] Approximate the derivatives asdidt∼= i(t+ δt)− i(t)δt,dψdt∼= ψ(t+ δt)− ψ(t)δtto get a pair of recursive equations for i(t+ δt) and ψ(t+ δt) in terms of i(t) and ψ(t).(d) [3 marks] Write a MATLAB function RLCSolver that takes eight inputs and returns two outputs.The inputs should be the values of R, L, C, T , Vs, i(0), ψ(0), and δt. The first output shouldbe a vector containing the values of t and the second output should be a vector containing thecorresponding values of i(t).(e) [2 marks] Write a MATLAB script RLCPlotter2e that makes use of RLCSolver to produce a plotshowing i(t) for C = 1 F, T = 20 s, Vs = 10 V, i(0) = 0 A, ψ(0) = 0 As−1, δt = 0.1 s and all fourpossible combinations of R = 1 Ω or R = 2 Ω and L = 1 H or L = 2 H. Ensure the plot containsaxis labels as well as a legend. Note that the current should converge to the same value as in theRL circuit for t→∞.−+VsRiLCFigure 2: RLC circuit.Submission guidelines• Your MATLAB scripts and functions should all be different files (please use the suggested names).• Your answers to 1(a), 1(b), 2(a), 2(b), and 2(c) can either be in a single file or multiple files. Typed orscanned handwritten answers are both fine.• Include all files in a single zip file and submit on MyLO. Please include your name and student numberin the name of the zip file.2