# Plotting the bode plot of a high pass filter using matlab

I am trying to theoretically find the frequency response of the circuit given below:

Firstly i found the impedance value of the RC Ladder by applying the equation below, then i defined this as "Z" in my MatLab Code.

Afterwards i wrote a matlab code to plot the filter's frequency response. Matlab Code is given below, the required nominal values shown in the schematic are defined in the code.

f = logspace(0, 5, 1000);
w=2*pi.*f;
s=1i.*w;

Ro=11960e3;
R1=2.17e3;
R2=118.44e3;
R3=496.82e3;
R4=1220e3;
R5=2530e3;

C1=536.29e-12;
C2=217.23e-12;
C3=201.41e-12;
C4=263.35e-12;
C5=556.27e-12;

Rload=200e3;

Z=((1/Ro)+(R1+(1./(s*C1)))+(R2+(1./(s*C2)))+(R3+(1./(s*C3)))+(R4+(1./(s*C4)))+(R5+(1./(s*C5)))).^-1;

H=abs(Rload./(Z+Rload));
semilogx(f, 20*log10(H))


The LTSpice plot (expected one) is like this:

My Matlab Plot is like this:

My mathematical approach seems correct to me let me know if i have anything missing on that part. I am unsure about the code, please let me know if there is something missing in code or my mathematical approach.

• (Socratic Question) What's the impedance of a simple RC-series circuit with only one resistor and one capacitor? Commented May 13 at 19:46
• @Colin isn't it R+1/(jwC)? Am i missing something haha? Commented May 13 at 19:56
• Well... yes but in bode plots, you can't have imaginary values. What's the magnitude of the impedance? (I guess I should have asked that first) Commented May 13 at 20:03
• @Colin Ah yes i am aware of that, as far as i know the Matlab's abs() function takes automatically magnitude of a complex number (correct me if i am wrong). I thought this line of code would remove the imaginary part "H=abs(Rload./(Z+Rload));". Commented May 13 at 20:06