% Program for modeling a CATV channel blocker
% K. A. Connor 10 November 1999 
% Updated 4 February 2007
% In the file, the given stub length d is specified for the first type of
% analysis. Also, the specific frequency F is specified for a range of stub
% lengths for the second type of analysis. To change conditions, this file
% must be edited.

% The frequency range covers all of the CATV bands and a bit more
% The characteristic impedance is the usual 75 Ohms
% The length of the stub is d and the load for the stub is Zl
f=[5:.1:65]*1e7;
Zo=75; d=.5; beta=2*pi*f/2e8;Zl=1e9;

% Input impedance of the stub

Zin=Zo.*(Zl+j.*Zo.*tan(beta.*d))./(Zo+j.*Zl.*tan(beta.*d));

% Parallel Combination of Zin and Zo

Ztotal=1./(1./Zin+1./Zo);

% Reflection Coefficient Seen by the First Transmission Line due to the
% Combination of Zin and Zo

Ref=(Ztotal-Zo)./(Ztotal+Zo);

% Transmission Coefficient for the Same Conditions

Trans=1+Ref;

%Plotting Results

% Zin for the Stub
plot(f,real(Zin),'.',f,imag(Zin),'-',f,abs(Zin));legend('Real Zin', 'Imag Zin', 'Abs Zin');
title('Input Impedance of the Stub of Fixed Length d');xlabel('Frequency');grid;figure;

% Reflection Coefficient
plot(f,real(Ref),'.',f,imag(Ref),'-',f,abs(Ref));legend('Real Ref', 'Imag Ref', 'Abs Ref');
title('Reflection Coefficient for Fixed Stub Length d');xlabel('Frequency');grid;figure;

%Transmission Coefficient
plot(f,real(Trans),'.',f,imag(Trans),'-',f,abs(Trans));legend('Real Trans','Imag Trans','Abs Trans');
title('Transmission Coefficient for Fixed Stub Length d');xlabel('Frequency');grid;figure;

%Determine Frequency for Minimum Trans (work in progress -- ignore for now)
%[y,ii]=min(abs(Trans));
%freq=f(ii)

% Determine Lengths for a Particular Frequency
% Frequency F should be input by user as should the range of lengths L
% by editing this file
% Note that the selection of short circuit or open circuit stub is still
% the same as above

F=1.75e8;
B=2*pi*F/2e8;
L=[0:.002855:2];

Zin=Zo.*(Zl+j.*Zo.*tan(B.*L))./(Zo+j.*Zl.*tan(B.*L));
Ztotal=1./(1./Zin+1./Zo);
R=(Ztotal-Zo)./(Ztotal+Zo);
T=1+R;
plot(L,real(T),'.',L,imag(T),'-',L,abs(T));legend('Real T', 'Imag T', 'Abs T');
title('Transmission Coefficient for Selected Frequency for a Range of Stub Lengths');xlabel('Length');grid;

