⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acquire trace single.m

📁 Agilent 仪器与MATLAB互联
💻 M
字号:
% MATLAB/MXA example 3
% Getting and plotting trace data
% Single trace aquisition	

% Version: 1.0
% Date: Sep 11, 2006  
% 2006 Agilent Technologies, Inc.

oldobjs=instrfind;
if ~isempty(oldobjs)
disp('Cleaning up ...')
delete(oldobjs);
clear oldobjs;
end

% Initial setup
mxa_ip = '141.121.92.157';
mxa_port = 5025;

mxa=tcpip(mxa_ip, 5025);
% input buffer size to receive trace data
% should be at least 4 times the number of trace
% points for 32-bit real format
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,'float32'); % get the trace data
fscanf(mxa); %removes the terminator character

% create and bring to front figure number 1
figure(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 mxa;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -