User`s guide

Spectral Analysis Example
Spectral Analysis Example
This example illustrates the creation of a comprehensive Excel add-in to
perform spectral analysis. It requir es knowledge of Visual Basic forms and
controls, as well as Excel workbook events. See the VBA documentation for a
complete discussion of these topics.
The example creates an Excel add-in that performs a fast Fourier transform
(FFT) on an input data set located in a designated worksheet range. The
function returns the FFT results, an array of frequency points, and the power
spectral density of the input d ata. It places these results into ranges you
indicate in the current worksheet. You can also optionally plot the p ow er
spectral density.
You develo p the function so that you can invoke it from the Excel Tools menu
and can select input and output ranges through a GUI.
Creating the add-in requires four basic steps:
1 Build a standalone COM component from MATLAB code.
2 Implement the necessary V BA code to collect input and dispatch the calls
to your component.
3 Create the G
UI.
4 Create an Excel add-in and package all necessary components for
application deploym en t.
Building the Component
Your component will have one class with two methods, computefft and
plotfft.Thecomputefft me tho d computes the FFT and power spectral
density of the input data a nd computes a vector of frequency points based
on the length of the data entered and the sampling interval. T he
plotfft
method performs the same operations as computefft, but also plots the
input d ata and the power spectral density in a MATLAB Figure window. The
MATLAB code for these two methods resides in two M-files,
computefft.m
and plotfft.m.
3-13