Question: B . Simulating the RLC circuit in MATLAB ( 3 0 % ; 2 5 % ) In this section, you will use MATLAB to

B. Simulating the RLC circuit in MATLAB (30%;25%)
In this section, you will use MATLAB to solve the ODEs you derived in Section A. Matlab supports many different numerical
schemes for solving ODEs. Here you will use the solver ode45, which is based on a variable step Runge-Kutta method.
Assume R=2,L=10-3H and C=10-3F. Choosing as states x1=i and x2=vC, write a MATLAB function
xdot = RLCdynamics (t,x) that takes as inputs the time t and the vector of states x, and returns the vector of
time-derivatives of the state, xdot. Assume a constant input voltage of v(t)=1V. You may hard-code the values for
R,L and C given above or, alternatively, use global variables. Note: Your derivatives will not explicitly depend on the
time t. The reason the function RLCdynamics takes t as an argument is that MATLAB's ODE solvers expect this
particular form.
Solve the system of ODEs numerically for the initial condition i(0)=vC(0)=0 on the time interval tin[0,4*10-2] by
calling [t,x]= ode 45(@RLCdynamics,tspan,x0). This uses the ode 45 solver with standard settings. Consult
the MATLAB documentation for ode 45 about how to choose the values of tspan and initial state vector x0.
Plot the evolution of the current i and the capacitor voltage vC as a function of time in a single plot.
B . Simulating the RLC circuit in MATLAB ( 3 0 %

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!