AnsweredAssumed Answered

Saving .S2P and .CTI trace files to Matlab from PNA

Question asked by stinger on Jul 14, 2008
Latest reply on Jul 15, 2008 by stinger
I had a question regarding saving S11 and S21 measurement data as trace files (S2P and CTI) to my PC from my network analyzer (Agilent N5242A PNA-X) using Matlab.

I would like to transfer the data to Matlab, then save it once in Matlab.

here is the code I'm working with: (as you can tell, I'm also new to programming with the VNA.)

VNA = tcpip( '', 5025 );
set( VNA, 'InputBufferSize', 9000000 );

set( VNA, 'Timeout', 100 );

% Open socket
fopen( VNA );

fprintf( VNA, 'SYSTem:PRESet' );

% Define Measurement
fprintf( VNA, 'CALC:PAR:DEF:EXT CH1_S21,S21' );

% Select the measurement
fprintf( VNA, 'CALC:PAR:SEL CH1_S21' );

% Display Measurement (as Trace 2) - cannot select as trace 1 yet because I always get an error saying that you cannot write over trace 1
fprintf( VNA, 'DISP:WIND1:TRAC2:FEED CH1_S21' );

% Set sweep time to linear
fprintf( VNA, 'SENSe1:SWEep:TYPE LIN' );

% Set IF bandwidth to 700 Hz
fprintf( VNA, 'SENSe1:BANDwidth 700' );

% Set center frequency
fprintf( VNA, 'SENSe1:FREQuency:CENTer 800Mhz' );

% Set span frequency
fprintf( VNA, 'SENSe1:FREQuency:SPAN 800Mhz' );

% Set number of points
fprintf( VNA, 'SENSe1:SWEep:POINts 1000' );

% Set sweep generation mode to Analog
fprintf( VNA, 'SENSe1:SWEep:GENeration ANAL' );

% Set sweep time to Automatic
fprintf( VNA, 'SENSe1:SWEep:TIME:AUTO ON' );

% Save Trace (Not working)

% Trace2 = binblockread (VNA,'float');

% Read the sweep time (in seconds)
% SweepTime = query ( VNA, 'SENSe1:SWEep:TIME?' );

% Close socket
fclose (VNA)

If anyone could help it would be greatly appreciated.


ps: Also, for some reason I have to make my measurement in Trace 2, because I get an error if I try to make it in Trace 1