MATLAB Scripting

The Analyzer software is written entirely in MATLAB and utilizes some MATLAB functions and objects that can be used by end users to easily interact with converted IDE files in MATLAB.

In this Article


SlamStick Object Structure

The SlamStick object has a large nested structure that is analogous to the structure of our .IDE file's structure.  Many fields in the object will go unused for any given file, depending on the hardware configuration and the firmware revision.  The most relevant information will be stored in SlamStick.recordingProperties as a RecordingProperties object.  Most of that object's fields store data in plain formats, or as an empty array when that field is empty. The fields bwLimits, channels, sensors, and warnings will each contain a list of objects relevant to the recording; channels and sensors are of particular interest. The Sensor object stores data about sensor hardware, with an ID, a name, a BWLimit ID, and any traceability data.  The Channel objects store information about each channel including a channel ID, calibration IDs, a name, and time scaling.  Each channel also includes a list of Subchannels that contain more specific information about the subchannel, including a subchannel ID, a calibration ID, a name, and a reference to the physical sensor this subchannel is for.  Other information is accessible from these objects and descendants; for more specifics about the structure of the SlamStick, run the following in Matlab:

>> doc SlamStick

SlamStick Methods

[fftOut, freqsOut] = SlamStick.fft(channelId, subchannelId, calibrated, filtered, startTime, endTime)

Calling this method on a SlamStick object returns the FFT and frequencies of the subchannel specified by subchannelId from the channel specified by channelId.  If calibrated and filtered are true, then the FFT will be generated with data that has been converted from raw units to engineering units, and run through a filter by calling SlamStick.getFilteredData(channelId, subchannelId).  If only calibrated is true, then the data will be converted into engineering units, and no filter will be applied, by calling SlamStick.getCalibratedData(channelId, subchannelId).  If calibrated is false, then the FFT will be calculated using raw sensor data.  The FFT is limited to data between startTime and endTime.

[psdOut, freqsOut] = SlamStick.psd(channelId, subchannelId, calibrated, filtered, startTime, endTime)

Calling this method on a SlamStick object returns the PSD and frequencies of the subchannel specified by subchannelId from the channel specified by channelId.  The PSD is calculated from the FFT by passing all of this method's arguments to SlamStick.fft.  

[times, freqs, spectro] = SlamStick.spectrogram(channelId, subchannelId, window, overlap, isPsd, calibrated, filtered)

This method calculates a spectrogram of the data from the subchannel subchannelID on the channel channelId.  The window argument determines the size and shape of the window used in the spectrogram; if window is a scalar, then the window used will be a rectangular window with length window, if window is a vector, then window will be used as the windowing function.  Overlap is a scalar in the range [0,1), that determines the number of steps that overlap each window, as the product of  the window length and overlap. IsPsd is not currently implemented.   Calibrated and filtered determine if the spectrogram is generated using raw, calibrated, or filtered data; if calibrated and filtered are true, then the spectrogram will use filtered data, if only calibrated is true, then the spectrogram will be generated using data converted into engineering units, otherwise it will be generated using raw sensor data.

out = SlamStick.getCalById(id)

This method returns the calibration polynomial with the given id, or a new UnivariatePolynomial object that represents a 1:1 linear response.

out = SlamStick.getChannelList()

The method SlamStick.getChannelList returns a vector of all channelIDs in this SlamStick object.

out = SlamStick.getSubchannelList(channelId)

This method returns a vector of all subchannelIDs in the channel channelId in this SlamStick object.

out = SlamStick.getChannelPropsByID(channelId)

This method returns the properties for the channel specified by channelId.  

out = SlamStick.getCalibratedData(channelId, [subchannelId])

The method SlamStick.getCalibratedData returns the data on the channel channelId from the SlamStick converted to engineering units.  If subchannelId is not passed, then this method returns an array with all subchannels, otherwise it only returns the subchannel specified by subchannelId.

out = SlamStick.getFilteredData(channelId, [subchannelId])

This method returns calibrated data that has also been filtered by the filter stored in SlamStick.filterPolys.  If no filter exists, then a new fourth order butterworth filter with a frequency range of 0.5Hz to 0.2 times the sampling frequency is used.  If  subchannelId is not passed, then this method returns an array with all subchannels, otherwise it only returns the subchannel specified by subchannelId.  If a channels sampling rate is below 10Hz, then a filter will not be applied.  This method uses functions from the Matlab Signals Processing Toolbox, and may not work if you do not have it installed.

out = SlamStick.getFullTimesList(channelId)

This method returns the times for the data from the channel specified by channelId.  

out = SlamStick.getFrequency(channelId)

This method returns the frequency for the channel specified by channelId.

out = SlamStick.getRawData(channelId, [subchannelId])

This method returns the raw sensor data for the channel specified by channelId.  If subchannelId is passed, then only the data for the subchannel it specifies will be returned, otherwise an array with all subchannels will be passed.

out = SlamStick.getSubchannelPropsByID(channelId, subchannelId)

This method returns the properties of the subchannel specified by subchannelId, on the channel specified by channelId.

out = SlamStick.getUnits(channelId, subchannelId)

This method returns the units of the subchannel specified by  subchannelId, on the channel specified by channelId.

out = SlamStick.getChannelName(channelId, [subchannelId])

This method returns the name of the channel specified by channelId.  If subchannelId is passed, then it instead returns the name of the subchannel specified by subchannelId on the channel specified by channelId.


Download Library

The various files necessary for manipulating converted MATLAB files can be downloaded here.


Example Load Files

The package of MATLAB files contains two scripts that help demonstrate how to manipulate the converted data:

  • DemoScript.m - Loads a predefined MAT file and the capacitive MEMS data (if it exists) and compares unfiltered vs filtered data in the plot, FFT, PSD, and spectrogram.  Note that you will need the signal processing toolbox for this script.
  • example_load.m - Prompts the user to select a converted MATLAB file.  It will check if the piezoelectric or piezoresistive accelerometer is present, if it was that data will be used, otherwise the capacitive MEMS data is used.  The DC offset is removed with a simple median removal, then the data is plotted, along with a FFT, PSD, and phase plot.