%% Inverted Microstrip Design and S-Parameters
% This example shows you how to design an inverted microstrip line at 3 GHz for a FR4 substrate, copper conductor, line length of 0.5\lambda, reference impedance of 75\Omega, and the following ratio:
% \frac{\textrm{Thickness}\;\;\textrm{of}\;\textrm{the}\;\textrm{air}\;\textrm{layer}}{\textrm{Thickness}\;\;\textrm{of}\;\textrm{the}\;\textrm{substrate}}=\frac{12\ldotp 8e-4}{3\ldotp 2e-4}
% Compare S-parameters obtained from EM and behavioral modeling when the transmission line is terminated with 50\Omega.
%% Design Inverted Microstrip
% Use dielectric and metal libraries to create an inverted prototype microstripLine and apply design.

dFR4 = dielectric('FR4');
dFR4.Thickness = 3.2e-4;
dAir = dielectric('Air');
dAir.Thickness = 12.8e-4;

dInverted = dielectric('Name',{dAir.Name, dFR4.Name},...
    "EpsilonR",[dAir.EpsilonR dFR4.EpsilonR], ...
    "LossTangent",[dAir.LossTangent dFR4.LossTangent],...
    "Thickness",[dAir.Thickness dFR4.Thickness]);
inversePrototype = microstripLine('Substrate',dInverted, ...
    'Conductor',metal('Copper'),...
    "Height",dAir.Thickness);
show(inversePrototype)

% Use design method to obtain the transmission line.

tx = design(inversePrototype,3e9,'Z0',75,'LineLength',0.5);
show(inversePrototype)

%% Plot S-Parameters

freq = (1:40)*100e6;
Sem = sparameters(tx,freq,50);
Srf = sparameters(tx,freq,50,'Behavioral',true);
rfplot(Sem,'-x','db')
hold on
rfplot(Srf,'-s','db')
title('EM S vs. behavioral S abs, freq=(1:40)*100e6')

% Copyright 2020 The MathWorks, Inc.