basic control using scpi.m

来自「Agilent 仪器与MATLAB互联」· M 代码 · 共 44 行

M
44
字号
% MATLAB/MXA example 1
% A first MATLAB/MXA program using basic SCPI commands 

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

% TCPIP parameters of the MXA box
mxa_ip = '141.121.92.157';
mxa_port = 5025;

% MXA Interface creation and connection opening
fprintf('\nConnecting to MXA ...\n');
mxa = tcpip(mxa_ip,mxa_port);
fopen(mxa);
 
% Intrument identification
idn = query(mxa,'*IDN?');
fprintf('Hello from %s', idn);

% Set the center frequency to 1 GHz
fprintf(mxa,':FREQ:CENT 1 GHz');

% Set the span to 20 MHz
fprintf(mxa,':FREQ:SPAN 20 MHz');

% Set the reference level to +10 dBm
fprintf(mxa,':DISP:WIND:TRAC:Y:RLEV 10');

% Query the resolution bandwidth using fprinf()/fgets()
fprintf(mxa,':BAND:RES?');
rbw = str2double(fgets(mxa));
fprintf('Resolution bandwidth: %d kHz\n', rbw/1e3);

% Query the sweep time using query()
swp = str2double(query(mxa,':SWE:TIME?'));
fprintf('Sweep time: %d ms\n', round(swp*1000));

% Close the MXA connection and clean up
fprintf('Disconnecting from MXA ...\n');
fclose(mxa); 
delete(mxa); % delete the interface object
clear mxa;   % clear from the workspace

⌨️ 快捷键说明

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