rd-ckt
rd-ckt
% Define the frequency range to analyze f_start = 1; % Start frequency in Hz f_end = 1e5; % End frequency in Hz
num_points = 200; % Number of frequency points f = logspace(log10(f_start), log10(f_end), num_points); %
Logarithmically spaced frequencies
% Calculate the impedance of the capacitor as a function of frequency Z_C = 1 ./ (1j * 2 * pi * f * C);
% Calculate the transfer function H(f) = V_out(f) / V_in(f) % Assuming V_out is the voltage across the capacitor H_f =
Z_C ./ Z_total;
% Calculate the phase of the transfer function in degrees phase_degrees = angle(H_f) * 180 / pi;
% Plot the magnitude response figure; subplot(2, 1, 1); semilogx(f, magnitude_dB); xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)'); title('Magnitude Response of RC Circuit'); grid on;
% Plot the phase response subplot(2, 1, 2); semilogx(f, phase_degrees); xlabel('Frequency (Hz)'); ylabel('Phase
(degrees)'); title('Phase Response of RC Circuit'); grid on;
% Theory: This code analyzes a series RC circuit, which is a fundamental % building block in many electronic systems
(filters, timing circuits, etc.). % The impedance of a resistor is constant (R), while the impedance of a % capacitor is
frequency-dependent (Z_C = 1/(jωC), where ω = 2πf is the % angular frequency). The transfer function H(f) describes
how the circuit % modifies the amplitude and phase of an input signal at different frequencies. % For a low-pass RC
filter (V_out across C), the magnitude response shows % attenuation of high frequencies, and the phase response shows
a lagging % phase shift that increases with frequency.