Newsletters - MATLAB Digest
Data Streaming from the Instrument Control Toolbox to an Excel Spreadsheet
Filtering the Acquired Data
To filter out artifacts and smooth out the quantization noise introduced by the digitization of the waveform, you can use an IIR filter with the Filter Design and Analysis (FDA) Tool included in the Signal Processing Toolbox. The Signal Processing Toolbox documentation explains the filter design process and the FDA Tool.
To use the filter function from the Signal Processing Toolbox, enter the coefficients generated by the FDA Tool.
a = [ 1.0000000e+000 -7.8781552e-001 ];
b = [ 1.0609224e-001 1.0609224e-001 ];
Filter the signal.
data = filter( b, a, data);
MATLAB Control of Excel
ActiveX objects such as an Excel application require you to build the MATLAB link to Excel as a client-server model. In this context, MATLAB is the client to the Excel server and the MATLAB client requests that the Excel server execute specific commands.
The following steps display a MATLAB array in Excel:
- Initialize the server.
- Add a workbook
- Select the active worksheet
- Put a MATLAB array into Excel
- Select a range in the worksheet
- Fill the range with the MATLAB array.
- Add a chart.
- Annotate the chart
- Set the data in the chart.
The first step is to create the server. The MATLAB command that initializes an ActiveX Server as ACTXSERVER. This command returns a handle to the default interface of the server. The required parameter is the program ID, which comes from the program's documentation. There are two ways of instantiating the server:
- in the local machine (i.e., the machine where MATLAB is running)
- in a remote machine that is available on the network
The latter requires an extra input parameter for the network machine name. You will assume that Excel is available locally.
Excel = actxserver('Excel.Application')
Excel =
com.excel.application
The Visible property brings the Excel window to the top of the computer desktop and makes it visible.
set(Excel, 'Visible', 1);
Adding a Worksheet to Excel
A spreadsheet, also known as a worksheet, is an entity that belongs to a workbook. To add a new workbook, use the handle to the Excel server that you created in the last step. The dot operator in MATLAB allows you to access the Excel Workbooks interface handle.
Workbooks = Excel.Workbooks;
Use the Workbooks interface handle to invoke its Add method.
Workbook = invoke(Workbooks, 'Add');
![]() |
There may be more than one workbook in use at one time. By default, a workbook has three sheets. To access a worksheet, you need a handle from the current active workbook to the Sheets interface. |
Sheets = Excel.ActiveWorkBook.Sheets;
Next, you need to get a handle to the currently active sheet. Since the default sheet is Sheet1, you do not need to make it active. All that is needed is to simply get its handle.
Activesheet = Excel.Activesheet;
Store

