%% Use Behavioral Model to Calculate S-Parameters of Microstrip T-Junction
% Design a microstrip transmission line at 3 GHz for FR4 substrate.

m = design(microstripLine('Substrate',dielectric('FR4')),3e9);

%
% Create a microstrip T-junction.

layer2d = traceTee('Length',[m.Length m.Length/4],...
"Width",[m.Width m.Width/2]);

%
% Convert the T-junction trace to a 3-D component.

robj = pcbComponent(layer2d);
robj.BoardThickness = m.Substrate.Thickness;
robj.Layers{2} = m.Substrate;
show(robj)

%
% Define frequency points to calculate the s-parameters.

freq = (1:40)*100e6;

% Calculate the s-parameters of the T-junction trace using the behavioral model.

Sckt = sparameters(robj,freq,75,'Behavioral',true);

% Calculate the s-parameters of the T-junction trace using the electromagnetic solver.

Sem = sparameters(robj,freq,75)

%
% Plot the s-parameter data using the rfplot function.

rfplot(Sckt,1,1,'db','-s')
hold on
rfplot(Sem,1,1,'db','-x')
rfplot(Sckt,2,1,'db','-s')
rfplot(Sem,2,1,'db','-x')
rfplot(Sckt,3,1,'db','-s')
rfplot(Sem,3,1,'db','-x')

% References:
% Ramesh Garg & I. J. Bahl (1978) Microstrip discontinuities, International Journal of Electronics, 45:1, 81-87, DOI: 10.1080/00207217808900883
%  Wadell, Brian C. Transmission Line Design Handbook. The Artech House Microwave Library. Boston: Artech House, 1991.
% Copyright 2020 The MathWorks, Inc.