clc; clear; close all;
% Component values
R = 1e3; C = 100e-9; % Resistance in ohms
% Capacitance in farads
% Cutoff frequency
fc = 1/(2*pi*R*C);
fprintf('Cutoff frequency = %.2f Hz\\n', fc);
% Frequency vector and complex frequency
f = logspace(1,5,1000);
w = 2*pi*f;
s = 1j*w;
% Transfer functions
H_LPF = 1 ./ (1 + s*R*C);
H_HPF = (s*R*C) ./ (1 + s*R*C);
% Magnitude (dB) and phase (degrees)
LPF_dB = 20*log10(abs(H_LPF));
HPF_dB = 20*log10(abs(H_HPF));
LPF_phase = angle(H_LPF)*180/pi;
HPF_phase = angle(H_HPF)*180/pi;
figure;
subplot(2,1,1);
semilogx(f,LPF_dB,'b','LineWidth',1.8); hold on;
semilogx(f,HPF_dB,'r','LineWidth',1.8);
xline(fc,'--k','fc'); yline(-3.01,':k','-3 dB');
grid on; xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
title('First-Order RC Magnitude Response');
legend('LPF','HPF','Location','best');
subplot(2,1,2);
semilogx(f,LPF_phase,'b','LineWidth',1.8); hold on;
semilogx(f,HPF_phase,'r','LineWidth',1.8);
grid on; xlabel('Frequency (Hz)'); ylabel('Phase (degrees)');
title('First-Order RC Phase Response');
legend('LPF','HPF','Location','best');
To embed this project on your website, copy the following code and paste it into your website's HTML: