Finding the bandwidth of a parallel RLC circuit (+MATLAB)

AI Thread Summary
The discussion focuses on calculating the bandwidth of a parallel RLC circuit using MATLAB. The total impedance is derived from the individual impedances of the resistor, capacitor, and inductor, leading to a formula for Z_T. The user plots the impedance magnitude across various frequencies and attempts to determine the bandwidth by identifying -3dB points. However, varying the number of frequency samples (N) results in significant changes in the calculated bandwidth, which was initially puzzling. The issue was resolved after identifying an error in the MATLAB code, leading to more consistent bandwidth results.
ItsTheSebbe
Messages
10
Reaction score
1
Homework Statement
upload_2018-10-1_18-36-2.png

The attempt at a solution
Constructing the total impedance of the circuit as follows,
$$\frac{1}{Z_T}=\frac{1}{Z_R}+\frac{1}{Z_C}+\frac{1}{Z_L}$$
where $Z_R=R$, $Z_C=-j\frac{1}{\omega C}$ and $Z_L=j\omega L$.
$$\frac{1}{Z_T}=\frac{1}{R}+j\omega C+\frac{1}{j\omega L}$$
solving for $Z_T$ gives us,
$$Z_T=\frac{Rj\omega L}{j\omega L-RCL\omega^2+R}$$
where $\omega=2\pi f$
$$Z_T=\frac{2\pi fRLj }{2\pi fLj-RCL(2\pi f)^2+R}$$
Plotting this function over the frequencies, whilst $L=10\ \mu H$, $C=5\ pF$ and $R=10^6\ \Omega

From here, I created the following MATLAB code to find:
- The magnitude of the impedance (Z_Mag) for a range of frequencies.
- Finding the maximum of Z_mag and it's corresponding frequency.
- finding the -3db points and the frequencies that correspond to these points.
- taking the difference of said frequencies in order to calculate the bandwidth.
Code:
clear all 
close all

N=100000; %number of frequency samples
L=10*10^(-6); %inductance
C=5*10^(-12); %capacitance
R=10^6; %resistance
f=linspace(1,10^8,N); %frequency of 1 Hz to 100 MHz
df=f(2)-f(1);

Z_T=(2*pi*f*R*L*1i)./(2*pi*f*L*1i-R*C*L*(2*pi*f).^2+R); %impedance
Z_mag=abs(Z_T); %magnitude of the complex impedance

plot(f,Z_mag); %plotting the frequency against the total impedance
title('Total impedance per frequency')
xlabel('frequency')
ylabel('total impedance')

[max_Z, max_index]=max(Z_mag); %maximum value of impedance
threedb=max_Z*sqrt(2)/2; %the 3db point 

[Z_db,index_db] = min(abs(Z_mag-threedb)); %closest value and index to the 3db point
f1=index_db*df; %the first frequency at the 3db point 
%the second frequency at the 3db point (first frequency mirrored around the
%frequency at max magnitude
f2=(max_index+(max_index-index_db))*df; 

BW=abs(f2-f1); %the bandwidth

Now when I vary the N (number of frequency samples), the bandwidth I find seems to change quite drastically. Ideally, I would expect the bandwidth to asymptotically approach some value with a greater accuracy for a greater N.

I have been trying to found out what I did wrong for some time now, does anyone know where I went wrong? Thanks!
 

Attachments

  • upload_2018-10-1_18-35-59.png
    upload_2018-10-1_18-35-59.png
    53.7 KB · Views: 551
  • upload_2018-10-1_18-36-2.png
    upload_2018-10-1_18-36-2.png
    53.7 KB · Views: 1,218
Last edited:
Physics news on Phys.org
I found an error in my program, which solved the problem.
 
  • Like
Likes berkeman

Similar threads

Replies
17
Views
2K
Replies
5
Views
3K
Replies
21
Views
1K
Replies
2
Views
3K
Replies
1
Views
3K
Replies
1
Views
2K
Replies
6
Views
2K
Back
Top