% Display LogMag S21 
% Andrew Fletcher 24/2/22

% Configuration Section  -------------------------------------------------

% the serial port that the nanoVNA is connected to
nanoVNAport = 'COM6';

% End  of Configuration
% Do not edit below here -------------------------------------------------

hCom = nanoOpen(nanoVNAport);

% prompt for sweep
sweepStart = input('Sweep start (MHz)? ');
command = sprintf('sweep start %d', sweepStart * 1000000);
nanoCommand(hCom, command);

sweepEnd = input('Sweep stop (MHz)? ');
command = sprintf('sweep stop %d', sweepEnd * 1000000);
nanoCommand(hCom, command);

netwk = nanoGetData(hCom);

fig = figure('Name','LOGMAGS21', 'NumberTitle','off');

rfplot(netwk,2,1, '-b')

% close port
nanoClose(hCom);