Design Article
Tell us What You Think
We want to know what you thought about this Design. Let us know by adding a comment.
Automating communications measurement
Mike Woodward, MathWorks
12/3/2012 10:32 AM EST
Automating communications measurement involves more than merely creating a push-button interface to control instruments. An ideal automated system combines data analysis, instrument control, and reporting. For example, such a system might fit a model to measured data, compare model predictions to new measurement data, and summarize the results in a document. Most currently available automated systems are good at one of these tasks but not others—for example, a solution might offer excellent instrument control but poor data analysis abilities.
This article shows how you can automate the entire measurement process in MATLAB. We will demonstrate the automation through two examples. The first shows the combination of instrument control and data analysis in a MATLAB GUI. The second shows automated data analysis and report writing, and demonstrates how to create a standalone executable that can be shared with end users without exposing the underlying code.
The code samples discussed in this article are available for download.
Combining instrument control and data analysis
This example shows how you can combine measurement taking, data analysis, and visualization in one GUI-driven MATLAB application. Our goal is to model the response of an unknown circuit to a known input from an Agilent 33220A arbitrary waveform generator. Our test setup consists of an unknown circuit, an external sound card to capture the output of the unknown circuit, the waveform generator, and, of course, MATLAB (Figure 1).

Controlling an instrument involves creating and opening a session using a protocol object, writing commands to the session, and reading the instrument’s response. We can connect to and control an Agilent 33220A arbitrary waveform generator via the VISA interface using the following code:
Next, using the GUIDE tools in MATLAB we build a GUI-based application for real-time instrument control, data analysis, and visualization. Via the GUI, the user controls the instrument settings and starts the measurement process (Figure 2).

This article shows how you can automate the entire measurement process in MATLAB. We will demonstrate the automation through two examples. The first shows the combination of instrument control and data analysis in a MATLAB GUI. The second shows automated data analysis and report writing, and demonstrates how to create a standalone executable that can be shared with end users without exposing the underlying code.
The code samples discussed in this article are available for download.
Combining instrument control and data analysis
This example shows how you can combine measurement taking, data analysis, and visualization in one GUI-driven MATLAB application. Our goal is to model the response of an unknown circuit to a known input from an Agilent 33220A arbitrary waveform generator. Our test setup consists of an unknown circuit, an external sound card to capture the output of the unknown circuit, the waveform generator, and, of course, MATLAB (Figure 1).

Figure 1. A MATLAB application controlling a waveform generator and modeling the response of an unknown circuit.
The first step is controlling test equipment from MATLAB using Instrument Control Toolbox™. The toolbox enables us to control equipment via a variety of interfaces, including USB, LXI, and GPIB. It also provides instrument-specific drivers for many instruments from Agilent, Tektronix, Rohde & Schwarz, and other vendors.Controlling an instrument involves creating and opening a session using a protocol object, writing commands to the session, and reading the instrument’s response. We can connect to and control an Agilent 33220A arbitrary waveform generator via the VISA interface using the following code:
interfaceObj = visa(’AGILENT’, VISAaddress)As you can see, the code is straightforward.
% Create a device object.
fgen = icdevice(’agilent_33220a.mdd’, interfaceObj)
% Connect device object to hardware.
connect(fgen)
% Set the voltage amplitude to 0.2 V
set(fgen, ’Amplitude’, 0.2)
Next, using the GUIDE tools in MATLAB we build a GUI-based application for real-time instrument control, data analysis, and visualization. Via the GUI, the user controls the instrument settings and starts the measurement process (Figure 2).

Figure 2. Measurement, data analysis, and visualization GUI.
The application simultaneously receives data from the sound card and the waveform generator and displays it on the graphs. When the user clicks Develop Model, the underlying code analyzes the waveform data and the data from the unknown circuit, fitting a polynomial model to the data and displaying the fitting results as a function of signal frequency. When measurement-taking resumes after the model has been built, the application shows the difference between the measured and modeled data.
Navigate to related information

