Please Please post or explain the matlab script! Let us consider the same networ
ID: 1717143 • Letter: P
Question
Please Please post or explain the matlab script!
Let us consider the same network of HW3, Figure 1, with the parameter reported in Table 1 Which is the order of the system? How many input it has? Comment your answer. Obtain (manually) a state space representation of the circuit in the form: x(t) = Ax(t) + Bu(t) Assuming that you variable of interest is the current is resistor R_1 write an output equation that give youi_R1 and arrange it in the form: y(t) = Cx(t) + Du(t) Write a Matlab script that simulates the circuit of Figure 1 on the base of the obtained description and plots I_R1. Compare the results obtained integrating the system of equation using Euler Forward, Euler Backward, Trapezoidal Rule for three different time step sizes: 0.1 s, Is, 2s. Select a proper final time for the simulation. Write a Matlab script that compares the results obtained modeling the circuit using resistive companion and using state space representation. Use Euler Backward as integration method and IR1 for the comparison. Comment the results obtained. Use a time step sizes equal to 0.1 s. Select a proper final time for the simulation.Explanation / Answer
Considering the RC Circuit (also called RC network) shown in this figure
we can use the Kirchhoff’s current law (KCL) to write the following equation
and we can rearrange into the equation
The solution to the equation above is
where
Vm is the initial voltage across the capacitor
RC is the time constant
This solution represents the voltage across a discharging capacitor.
Now, to obtain the voltage across a charging capacitor, let us consider this figure that includes a voltage source
Again, using KCL, the equation describing the charging RC circuit is
If the capacitor is not charged initially, that is v0(t) = 0 when t = 0, then the solution to the equation above is given by
The following examples illustrate the use of Matlab for solving problems
related to RC circuits.
Assume that for the charging RC circuit above Vs = 10 volts and C = 10 microfarads. Plot the voltage across the capacitor if R equals 5k ohm, 10k ohms and 20k ohms. This just means that we are going to explore three time constants.
This code is one simple solution to the problem
% Define the voltage source
Vs = 10;
% Define the capacitor in the circuit
C = 10e-6;
% Define the time lapse that we're going to explore
t = 0 : 0.005 : 0.35;
% Define the resistors in each time constant and
% calculate the voltage across the capacitor
R1 = 5e3;
tau1 = R1*C;
V1 = Vs * ( 1 - exp(-t/tau1) );
R2 = 10e3;
tau2 = R2*C;
V2 = Vs * ( 1 - exp(-t/tau2) );
R3 = 20e3;
tau3 = R3*C;
V3 = Vs * ( 1 - exp(-t/tau3) );
% Plot the responses, all at once
plot(t, V1, 'b-', t, V2, 'ro', t, V3, 'k*')
grid on
title('Transient Analysis - RC circuit')
xlabel('Time (s)')
ylabel('Voltage across capacitor (V)')
legend(['RC_1 = ' num2str(tau1)],...
['RC_2 = ' num2str(tau2)],...
['RC_3 = ' num2str(tau3)], 'location', 'best')