File Exchange

image thumbnail

Segmented smooth function

version (9.44 KB) by Tom O'Haver
Multiple segment variant of fastsmooth.m


Updated 19 Nov 2016

View License

SegmentedSmooth(y,w,type,ends) divides y into a number of equal-length
segments defined by the length of the vector 'smoothwidths', then
smooths each segment with smooth of type 'type' and width defined by
the elements of vector 'smoothwidths'. Same syntax as fastsmooth.
Version 1, November 2016.
The argument "type" determines the smooth type:
If type=1, rectangular (sliding-average or boxcar)
If type=2, triangular (2 passes of sliding-average)
If type=3, pseudo-Gaussian (3 passes of sliding-average)
If type=4, pseudo-Gaussian (4 passes of same sliding-average)
If type=5, multiple-width (4 passes of different sliding-averages)
The argument "ends" controls how the "ends" of the signal
(the first w/2 points and the last w/2 points) are handled.
If ends=0, the ends are zero. (In this mode the elapsed
time is the fastest and is independent of the smooth width).
If ends=1, the ends are smoothed with progressively
smaller smooths the closer to the end. (In this mode the
elapsed time increases with increasing smooth widths).
SegmentedSmooth(Y,w,type) smooths with ends=0.
SegmentedSmooth(Y,w) smooths with type=1 and ends=0.

Examples: 3-segment smooth of random white noise, smooth widths of
2,20, and 200.
plot(x,SegmentedSmooth(y,[2 20 200],3,0))

20-segment smooth, odd smooth widths from 1 to 41:

Cite As

Tom O'Haver (2021). Segmented smooth function (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!