Code covered by the BSD License  

Highlights from
Generating Waveforms on Agilent MXG, ESG, PSG Signal Sources using MATLAB


4.2 | 5 ratings Rate this file 57 Downloads (last 30 days) File Size: 2.5 KB File ID: #24048

Generating Waveforms on Agilent MXG, ESG, PSG Signal Sources using MATLAB



08 May 2009 (Updated )

MATLAB® example to download arbitrary waveform data on Agilent MXG, ESG, or PSG signal sources.

| Watch this File

File Information

MATLAB is a software environment and programming language with over 1,000,000 users and is used to generate arbitrary and standard waveforms, configure and control instruments, build automated test applications, and analyze and visualize data from other instruments. MATLAB only supports instrument communication when you use MATLAB with its Instrument Control Toolbox™.

This example uses MATLAB to generate an arbitrary waveform (IQ data), configure the instrument, download the waveform to the Agilent source, and instruct the instrument when to source the waveform.

To execute this example, type ‘Generate_Waveform_Agilent’ in the MATLAB command window. [Note: Change the IP address in the generate_agilent_waveform.m file to the IP address of the signal source.]

This MATLAB example has been tested on an N5182A MXG but should work on other Agilent signal sources including these MXG, ESG, and PSG models: E4428C,E4438C,N5181A,N5182A,N5183A,E8241A,E8244A,E8251A,E8254A,E8247C,E8257C, E8267C,E8257D,E8267D,E8663B,N8211A,N8212A.

To learn more about using MATLAB and Instrument Control Toolbox™ for configuring and controlling instruments, visit:

To request a trial of MATLAB and/or Instrument Control Toolbox, visit

For additional information on using MATLAB with Agilent instruments, including MATLAB examples, demos, drivers, and videos, visit:

Required Products Instrument Control Toolbox
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
16 Apr 2014 zhang

does agilent waveform download asisstant do the same work?

05 Mar 2014 hao  
22 Nov 2013 Ryan

Great work on connect MATLAB and Agilent instruments.

16 Aug 2012 Attique Ur Rehman

Hello all,
First of all thanks for the script, secondly I tried the code on Agilent N5182A but unfortunately the N5182A display an error i.e. "ERROR_ -275, File name error"

Waiting for a kind response...

18 May 2011 Cheah Wei Leow

MATLAB_WFM is it a file?

20 Jan 2010 Nikola Stanchev


Thank you for this script. It is very useful except a bug that should be corrected.
I have formatted/scaled waveform by using this script. I was successful to download it to Agilent Signal generator PSG E8267D.

Unfortunately, the PSG output signal (with ARB waveform modulation) was not as suppose to be. I expected to see burst spread spectrum signal but I've got flat signal with a few dB variations.

After a few hours investigation of the problem I found that the cause is the use of Two's complement formatting in the Matlab code.

wave = uint16(mod(modval + wave, modval));

I've got the correct PSG's output signal without 2's complement formatting.

If you go to the Agilent PSG programming guide (E8251-90255) you can see the following sentence "...Data must be in signed, 2’s complement (binary) format..." (very interesting combination, isn't it?)
There is no use of 2's complement formatting in the attached examples script in C/C++.

Best regards,

14 Sep 2009 Marco

I have tried this program in an Agilent Signal Generator E8267D.

However, the instrument displays an error message -275 wrong file name after the line 59:
binblockwrite(deviceObject,wave,'uint16',[':MEM:DATA "WFM1:' ArbFileName '",']);

08 May 2009

Minor update

14 May 2009

Update to include VISA and basic interface functionality in example.

19 May 2009

Minor update.

21 Aug 2009

Updated description

21 Aug 2009

Updated description

30 Sep 2009

Change in copyright.

Contact us