% Kmitoctova charakteristika napetoveho prenosu dvojbranu RLC 
% -------------------------------------------------------------------------


R = 600;
C = 4.7E-8;
L = 0.02;

fs = 7e3;                                       % stredni kmitocet pro analyzu
d  = 4;                                         % pocet dekad

% -------------------------------------------------------------------------

d  = ceil(d);
f1 = sign(fs)*10^(round(log10(abs(fs))-(d/2))); % dolni mez rozsahu frekvenci
f2 = f1*10^d;                                   % horni mez rozsahu frekvenci
nc = 100*abs(d);                                % pocet vzorku f (100/dek)
if nc == 0, nc = 1; f1 = fs; f2 = fs; end

Vy = zeros(1,nc+1);  Vx = zeros(1,nc+1); 
q = (f2/f1)^(1/nc);
f = f1;

for n = 1 : nc+1   
    Omega = 2*pi*f;
    Yr = 1/R;
    Yc = i*Omega*C;
    Yl = -i/(Omega*L);
    YU = [Yc , -Yc , 0 ; -Yc , Yc+Yl+2*Yr , -Yr ; 0 , -Yr , Yr];
    D13 = det(YU([2,3],[1,2]));
    D11 = det(YU([2,3],[2,3]));
    Ku = abs(D13/D11);
    Vy(n) = Ku;
    Vx(n) = f;
    f = f*q;
end

if d==0, stem(Vx,Vy,'--s','fill')
    else semilogx(Vx,Vy,'LineWidth',2)
end
xlabel('frekvence [Hz]')
ylabel('napìtový pøenos')
title('Kmitoètová charakteristika','FontSize',14)
grid on
