Trans RL
Trans RL
voltage.
% Define circuit parameters R = 10; % Resistance (Ohms) L = 0.1; % Inductance (Henries) C = 1e-4; % Capacitance
(Farads) V_step = 5; % Amplitude of the step input voltage (V)
% Define simulation parameters t_start = 0; t_end = 0.1; dt = 1e-5; t = t_start:dt:t_end; num_steps = length(t);
% Initialize variables i = zeros(num_steps, 1); % Current in the circuit (A) q = zeros(num_steps, 1); % Charge on the
capacitor (C) vc = zeros(num_steps, 1); % Voltage across the capacitor (V)
% Simulation loop using Euler's method for n = 1:num_steps - 1 % Apply Kirchhoff's Voltage Law (KVL): V_in - V_R - V_L
- V_C = 0 % V_R = i * R % V_L = L * di/dt => di/dt = (V_in - i*R - vc) / L % i = dq/dt => dq = i * dt => q(n+1) = q(n) +
i(n) * dt % vc = q / C
end
% Plot the results figure; subplot(2, 1, 1); plot(t, i(1:num_steps-1)); xlabel('Time (s)'); ylabel('Current (A)');
title('Transient Response of Series RLC Circuit (Current)'); grid on;
subplot(2, 1, 2); plot(t, vc(1:num_steps-1)); xlabel('Time (s)'); ylabel('Capacitor Voltage (V)'); title('Transient Response of
Series RLC Circuit (Capacitor Voltage)'); grid on;
% Theory: This code simulates the transient behavior of a series RLC circuit % when subjected to a step input voltage.
Transient analysis is crucial for % understanding how circuits respond to sudden changes in input. The behavior % of
the RLC circuit is governed by a second-order linear differential equation % derived from Kirchhoff's Voltage Law (KVL)
and the voltage-current % relationships of resistors (V=IR), inductors (V=L di/dt), and capacitors % (i=C dv/dt or v =
1/C ∫i dt). The simulation uses Euler's method, a simple % numerical integration technique, to approximate the time
evolution of the % current and capacitor voltage. The transient response can exhibit oscillations % (underdamped),
critically damped behavior, or overdamped behavior depending % on the values of R, L, and C.