Vous êtes sur la page 1sur 3

clear all

clc
close all
A=input('Determine a configurao do circuito RLC:\n 1. Srie \n 2.
Paralelo \n ','s');

if strcmp(A,'1')
fres=input('Determine a frequncia de ressonncia \n');
betaaux=input('Determine a banda de largura em funo da
frequncia de ressonncia \n');
beta=betaaux*fres;
R=input('Determine o valor do resistor \n');
fatorq= fres/beta;
L=(R/(2*pi*beta));
C=(1/(((2*pi*fres)^2)*L));
fvaria=0:(fres/1000):2*fres;
n=length(fvaria);

for aux=1:1:n
ZL(aux)=2*pi*fvaria(aux)*L;
ZC(aux)=1/(2*pi*fvaria(aux)*C);
Zeq(aux)=(R^2+(ZL(aux)-ZC(aux)).^2).^0.5;
I(aux)=1/Zeq(aux);
ang(aux)=angle(R+i*(ZL(aux)-ZC(aux)))*180/pi;
VL(aux)=I(aux)*ZL(aux);
VC(aux)=I(aux)*ZC(aux);
VR(aux)=I(aux)*R;

end

subplot(2,2,1);plot(fvaria,ZL,'r',fvaria,ZC,'b',fvaria,R,'c',fvaria,Zeq,'
black')
set(gca,'XLim',[(fvaria(round(n/2+1))-3*beta)
(fvaria(round(n/2+1))+3*beta)])
title('Variao da Impedncia na frequncia')
hleg1 = legend('R. Indutiva','R.
Capacitiva','Resistor','Impedncia Total');
grid

subplot(2,2,2);plot(fvaria,I)
title('Variao da Corrente na frequncia')
hleg2 = legend('Corrente');
grid

subplot(2,2,3);plot(fvaria,ang)
title('Variao do angulo de fase da impedncia na frequncia')
hleg3 = legend('Fase');
grid

subplot(2,2,4);plot(fvaria,VR,'g',fvaria,VL,'b',fvaria,VC,'r')
title('Variao das tenses na frequncia')
hleg1 = legend('T. Resistor','T. Indutor','T. Capacitor');
grid
H=input('Analisar para diferentes valores de R e Q? \n 1. Sim \n
2. No \n','s');
if strcmp(H,'1')
for aux5=1:1:n
Iar(aux5)=1/((0.5*R)^2+(ZL(aux5)-ZC(aux5)).^2).^(0.5);
Ibr(aux5)=1/((2*R)^2+(ZL(aux5)-ZC(aux5)).^2).^(0.5);
Iaq(aux5)=1/(R^2+(0.5*(ZL(aux5)-ZC(aux5))).^2).^(0.5);
Ibq(aux5)=1/(R^2+(2*(ZL(aux5)-ZC(aux5))).^2).^(0.5);
end

figure

subplot(2,2,1:2);plot(fvaria,I,'b',fvaria,Iar,'r',fvaria,Ibr,'black')
title('R variando e Q constante')
hleg6=legend('R=1','R=0.5','R=2');

subplot(2,2,3:4);plot(fvaria,I,'b',fvaria,Iaq,'r',fvaria,Ibq,'black')
title('Q variando e R constante')
hleg7=legend('Q=1','Q=0.5','Q=2')
else
end

B=input('Determine o tipo de filtro:\n 1. Passa-Faixa \n 2. Rejeita


Banda \n ','s');
if strcmp(B,'1')
for aux2=1:1:n
ganho1(aux2)=1/((1+((1-
(2*pi*fvaria(aux2))^2*L*C)/(2*pi*fvaria(aux2)*R*C))^2))^0.5;
end
figure
plot(fvaria,ganho1)
else
for aux2=1:1:n
ganho1(aux2)=1/(1+((2*pi*fvaria(aux2)*R*C)/(1-
((2*pi*fvaria(aux2))^2*L*C)))^2)^0.5;
end
figure
plot(fvaria,ganho1)
end

else

fres=input('Determine a frequncia de ressonncia \n');


betaaux=input('Determine a banda de largura em funo da
frequncia de ressonncia \n');
beta=betaaux*fres;
R=input('Determine o valor do resistor \n');
C=1/(2*pi*beta*R);
L=(1/(((2*pi*fres)^2)*C));
fvaria=0:(fres/1000):2*fres;
n=length(fvaria);
for aux=1:1:n
ZL(aux)=(2*pi*fvaria(aux)*L);
YL(aux)=1/ZL(aux);
ZC(aux)=1/(2*pi*fvaria(aux)*C);
YC(aux)=1/ZC(aux);
Yeq(aux)=(YC(aux)-YL(aux));
Zeqa(aux)=1/Yeq(aux);
Zeq(aux)=(R^2+(Zeqa(aux))^2)^0.5;
I(aux)=1/Zeq(aux);
ang(aux)=angle(R+i*Zeqa(aux))*180/pi;
end

subplot(2,2,1:2);plot(fvaria,Zeq,'b')
grid
set(gca,'XLim',[(fvaria(round(n/2+1))-3*beta)
(fvaria(round(n/2+1))+3*beta)])
title('Variao da Impedncia na frequncia')
hleg=legend('Impedncia');

subplot(2,2,3);plot(fvaria,I)
title('Variao da Corrente na frequncia')
hleg2 = legend('Corrente');
grid

subplot(2,2,4);plot(fvaria,ang)
title('Variao do angulo de fase da impedncia na frequncia')
hleg3 = legend('Fase');
grid

B=input('Determine o tipo de filtro:\n 1. Passa-Faixa \n 2. Rejeita


Banda \n ','s');
if strcmp(B,'1')
for aux2=1:1:n
ganho1(aux2)=1/((1+(((2*pi*fvaria(aux2))^2*L*C*R-
R)/(2*pi*fvaria(aux2)*L))^2))^0.5;
end
figure
plot(fvaria,ganho1)
grid
else
for aux2=1:1:n
ganho1(aux2)=1/(1+((2*pi*fvaria(aux2)*L)/(R-
((2*pi*fvaria(aux2))^2*L*C*R)))^2)^0.5;
end
figure
plot(fvaria,ganho1)
grid
end
end

Vous aimerez peut-être aussi