File Exchange

Fast smoothing function

version 2.0.0.0 (52.4 KB) by
Fast smoothing function for time-series data

Updated 14 Feb 2017

Fastsmooth is a function of the form s=fastsmooth(a,w, type, edge). The argument "a" is the input signal vector; "w" is the smooth width; "type" determines the smooth type: type=1 gives a rectangular (sliding-average or boxcar); type=2 gives a triangular (equivalent to 2 passes of a sliding average); type=3 gives a pseudo-Gaussian (equivalent to 3 passes of a sliding average). The argument "edge" controls how the "edges" of the signal (the first w/2 points and the last w/2 points) are handled. If edge=0, the edges are zero. (In this mode the elapsed time is independent of the smooth width. This gives the fastest execution time). If edge=1, the edges are smoothed with progressively smaller smooths the closer to the end. (In this mode the execution time increases with increasing smooth widths). The smoothed signal is returned as the vector "s". (You can leave off the last two input arguments: fastsmooth(Y,w,type) smooths with edge=0 and fastsmooth(Y,w) smooths with type=1 and edge=0). Compared to convolution-based smooth algorithms, fastsmooth typically gives much faster execution times, especially for large smooth widths; it can smooth a 1,000,000 point signal with a 1,000 point sliding average in less than 0.1 second.

Cite As

Tom O'Haver (2021). Fast smoothing function (https://www.mathworks.com/matlabcentral/fileexchange/19998-fast-smoothing-function), MATLAB Central File Exchange. Retrieved .

Robert Buckles

It would be great to use for non-uniformly sampled data vectors, e.g. fastsmooth(X, Y, ...). Any plans to enhance it?

Ondrej Pleskac

Ali sameer

can you please share the resources

mahmood hassan

Luo

Yin Cheng

Tom O'Haver

Theron,
I copied and pasted that code example directly from your comment into Matlab and it worked perfectly. I've tested this in several versions of Matlab from 2009 to 2017. Make sure you have the latest version of fastsmooth.m (ver. 3.0, October 2016) in your Matlab path.

Teron Nguyen

I got this problem: "Subscript indices must either be real positive integers or logicals" from the code example:
x=1:100;
y=randn(size(x));
plot(x,y,x,fastsmooth(y,5,3,1),'r')
xlabel('Blue: white noise. Red: smoothed white noise.')
Anyone know why?
Thank you.

Nate Hobert

Emily Storey

imu931

Straightforward and user-friendly. Good codes & Thx.

Eliahu Ratner

Alex

Charles Johnson

Thank you for this! I found it irritating that matlab has a smooth function but it is in one of their specialized toolboxes. This seems like a basic enough function to have available in the main program. Anyways, thanks for uploading!

David Dijemeni

How can I apply fastsmooth to an image?

I am new to image processing in Matlab.

gurpreet kaur

thanks a lot,its a grt help to me

Conny

Mark Shore

Just as advertised, fast, efficient and does what it says.

Ale Cappe

Very good job, useful and quite straightforward.

Levent yüksek

Usefull and practical thanks.

Mingyang Yu

thank you for your help, it is great!

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