# mssgolay

Smooth signal with peaks using least-squares polynomial

## Syntax

* Yout* = mssgolay(

*,*

`X`

*)*

`Intensities`

mssgolay(

*,*

`X`

*, ...'Span',*

`Intensities`

*, ...)*

`SpanValue`

mssgolay(

*,*

`X`

*, ...'Degree',*

`Intensities`

*, ...)*

`DegreeValue`

mssgolay(

*,*

`X`

*, ...'ShowPlot',*

`Intensities`

*, ...)*

`ShowPlotValue`

## Arguments

`X` | Vector of separation-unit values for
a set of signals with peaks. The number of elements in the vector
equals the number of rows in the matrix .
The separation unit can quantify wavelength, frequency, distance,
time, or m/z depending on the instrument that generates the signal
data.`Intensities` |

`Intensities` | Matrix of intensity values for a set of peaks that share the
same separation-unit range. Each row corresponds to a separation-unit
value, and each column corresponds to either a set of signals with
peaks or a retention time. The number of rows equals the number of
elements in vector .`X` |

## Description

**Tip**

Use the following syntaxes with data from any separation technique that produces signal data, such as spectroscopy, NMR, electrophoresis, chromatography, or mass spectrometry.

smooths
raw noisy signal data, * Yout* = mssgolay(

*,*

`X`

*)*

`Intensities`

*, using a least-squares digital polynomial filter (Savitzky and Golay filters). The default span or frame is*

`Intensities`

`15`

samples.`mssgolay(`

calls * X*,

*, ...'*

`Intensities`

*',*

`PropertyName`

*, ...)*

`PropertyValue`

`mssgolay`

with optional properties
that use property name/property value pairs. You can specify one or
more properties in any order. Each *must be enclosed in single quotation marks and is case insensitive. These property name/property value pairs are as follows:*

`PropertyName`

```
mssgolay(
```

modifies
the frame size for the smoothing function. If * X*,

*, ...'Span',*

`Intensities`

*, ...)*

`SpanValue`

*is greater than*

`SpanValue`

`1`

, the window is the size of `SpanValue`

in
samples independent of the *vector. Higher values smooth the signal more with an increase in computation time. If*

`X`

*is less than*

`SpanValue`

`1`

,
the window size is a fraction of the number of points in the input
data, *. For example, if*

`X`

*is*

`SpanValue`

`0.05`

,
the window size is equal to `5%`

of the number of
points in *.*

`X`

**Note**

The original algorithm by Savitzky and Golay assumes the input
vector, * X*, has uniformly spaced separation
units, while

`mssgolay`

also allows one that is not
uniformly spaced. Therefore, the sliding frame for smoothing is centered
using the closest samples in terms of the *value and not in terms of the*

`X`

*index.*

`X`

When the input vector, * X*, does not
have repeated values or NaN values, the algorithm is approximately
twice as fast.

When the input vector, * X*, is evenly
spaced, the least-squares fitting is performed once so that the signal
is filtered with the same coefficients, and the speed of the algorithm
increases considerably.

If the input vector, * X*, is evenly
spaced and

*is even, span is incremented by*

`SpanValue`

`1`

to include both edge samples in the frame.

`mssgolay(`

specifies
the degree of the polynomial (* X*,

*, ...'Degree',*

`Intensities`

*, ...)*

`DegreeValue`

*) fitted to the points in the moving frame. The default value is*

`DegreeValue`

`2`

. *must be smaller than*

`DegreeValue`

*.*

`SpanValue`

`mssgolay(`

plots
smoothed signals over the original. When * X*,

*, ...'ShowPlot',*

`Intensities`

*, ...)*

`ShowPlotValue`

`mssgolay`

is
called without output arguments, the signals are plotted unless *is*

`ShowPlotValue`

`false`

.
When *is*

`ShowPlotValue`

`true`

,
only the first signal in *is plotted.*

`Intensities`

*can also contain an index to one of the signals in*

`ShowPlotValue`

*.*

`Intensities`

## Examples

## See Also

`mspalign`

| `msbackadj`

| `msdotplot`

| `msalign`

| `msheatmap`

| `mslowess`

| `msnorm`

| `mspeaks`

| `msresample`

| `msppresample`

| `mssgolay`

| `msviewer`

### Topics

- Mass Spectrometry and Bioanalytics
- Preprocessing Raw Mass Spectrometry Data
- Visualizing and Preprocessing Hyphenated Mass Spectrometry Data Sets for Metabolite and Protein/Peptide Profiling
- Differential Analysis of Complex Protein and Metabolite Mixtures using Liquid Chromatography/Mass Spectrometry (LC/MS)

**Introduced before R2006a**