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

📄 acquire trace cont async.m

📁 Agilent 仪器与MATLAB互联
💻 M
字号:
% MATLAB/MXA example 4
% Getting and plotting trace data
% Continuous trace aquisition (assync)

% 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);
set(mxa,'InputBufferSize',100000);
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?'));
% Put the instrument in continuos mode
fprintf(mxa,':INIT:CONT ON');

% Create and bring to front figure number 1
figure(1)
% Create a plot handle, ph,  and draw a line at the ref level
ph = plot(1:nr_points,ref_lev*ones(1,nr_points));
% 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
grid on

% Plot cycle
for i=1:100
    fprintf(mxa,':TRAC? TRACE1');
    data = binblockread(mxa,'float32');
    fscanf(mxa); %removes the terminator character

    % Change the plot line data (fast update method) 
    set(ph,'Ydata',data);
    % flushes the plot event queue
    drawnow
end

% Disconnect an clean up
fclose(mxa);
delete(mxa);
clear mxa;

⌨️ 快捷键说明

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