📄 rlc.m
字号:
clc;
clear all;
close all;
V0=7; %the power sources peak voltage
C=2.2*10^-6; %the capacity of the capacitor in Farads (2.2 uF)
L=0.01; %The coils inductance in Henries (10mH).
fr=sqrt(1/(4*pi*pi*L*C)); %formula that calculates the resonant
%frequency of a serial RLC circuit containing the inductor and capacitor above
R=0.5; %the coils inner resistance.
f=fr-500:1:fr+500; %Vektor that contains frequency values 500Hz above and
%below the resonant frequency with an interval of 1 Hz
w=2*pi*f; %angular speed of the voltagesource
xc=1./(C*w); %formula that calculates the impedance from the capacitor
xl=L.*w; %formula that calculates the impedance from the inductor.
r1=0;
r2=10;
r3=20;
R1 = r1+R; %Total resistance when there is no extra resistance
R2 = r2+R; %Total resistance when the extra resistor is 1 ohm
R3 = r3+R; %Total resistance when the extra resistor is 5 ohm
Z1 = sqrt(power(xc+xl,2)+power(R1,2));
Z2 = sqrt(power(xc+xl,2)+power(R2,2));
Z3 = sqrt(power(xc+xl,2)+power(R3,2));
i1=1000*V0./Z1;
i2=1000*V0./Z2;
i3=1000*V0./Z3;
%plot(f,xl,'r');hold on;plot(f,xc,'k');grid on;plot(f,Z1)
figure(1);
plot(f,i1,'r');hold on;plot(f,i2,'k');plot(f,i3,'g');grid on;
title('Current vs. frequency, Serial RLC circuit. ','Fontw','bold');
xlabel('Frequency [Hz]','Fontw','bold');ylabel('Current [mA] ','Fontw','bold');
legend(['R = ',num2str(R1),' Ohm'],['R = ',num2str(R2),' Ohm'],['R = ',num2str(R3),' Ohm'],'Location','Northwest')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -