Hi!
I need the Matlab code to get the plot of attenuation agains Frequency. I wrote one but i did not get the true plot. The spectrum analyzer is connected with GPiB. I hope u could help.
set(mxa,’InputBufferSize’,4005);
% instrument response timeout
set(mxa,’Timeout’,5);
fopen(mxa);
% Set the data trace format to REAL, 32 bits
fprintf(mxa,’:FORM:DATA REAL,32’);
% Get the nr of trace points
nr_points = str2double(query(mxa,’:SWE:POIN?’));
% Get the reference level
ref_lev = str2num(query(mxa,’:DISP:WIND:TRAC:Y:RLEV?’));
% Get the trace data
fprintf(mxa,’:INIT:IMM;*WAI’); % start a sweep and
%wait until it completes
fprintf(mxa,’:TRAC? TRACE1’);
data = binblockread(mxa,’fl oat32’); % get the trace data
fscanf(mxa); %removes the terminator character
% create and bring to front fi gure number 1
fi gure(1)
% Plot trace data vs sweep point index
plot(1:nr_points,data)
% Adjust the x limits to the nr of points
% and the y limits for 100 dB of dynamic range
xlim([1 nr_points])
ylim([ref_lev-100 ref_lev])
% activate the grid lines
grid on
title(‘Swept SA trace’)
xlabel(‘Point index’)
ylabel(‘Amplitude (dBm)’)
% Disconnect an clean up
fclose(mxa);
delete(mxa);
clear;
I need the Matlab code to get the plot of attenuation agains Frequency. I wrote one but i did not get the true plot. The spectrum analyzer is connected with GPiB. I hope u could help.
set(mxa,’InputBufferSize’,4005);
% instrument response timeout
set(mxa,’Timeout’,5);
fopen(mxa);
% Set the data trace format to REAL, 32 bits
fprintf(mxa,’:FORM:DATA REAL,32’);
% Get the nr of trace points
nr_points = str2double(query(mxa,’:SWE:POIN?’));
% Get the reference level
ref_lev = str2num(query(mxa,’:DISP:WIND:TRAC:Y:RLEV?’));
% Get the trace data
fprintf(mxa,’:INIT:IMM;*WAI’); % start a sweep and
%wait until it completes
fprintf(mxa,’:TRAC? TRACE1’);
data = binblockread(mxa,’fl oat32’); % get the trace data
fscanf(mxa); %removes the terminator character
% create and bring to front fi gure number 1
fi gure(1)
% Plot trace data vs sweep point index
plot(1:nr_points,data)
% Adjust the x limits to the nr of points
% and the y limits for 100 dB of dynamic range
xlim([1 nr_points])
ylim([ref_lev-100 ref_lev])
% activate the grid lines
grid on
title(‘Swept SA trace’)
xlabel(‘Point index’)
ylabel(‘Amplitude (dBm)’)
% Disconnect an clean up
fclose(mxa);
delete(mxa);
clear;
You can find an Agilent Vee programming example of how to pull trace data from an ESA at http://www.agilent.com/find/saprogramming This example program will illustrate the SCPI commands that are used to successfully pull the analyzer trace data. Hopefully, you can leverage and integrate this into your MatLab program.
Regards -