MATLAB Examples

scatstat2 documentation

The scatstat2 function returns statistical values of all points within a given radius of each value. This is similar to taking a moving mean, but points do not need to be equally spaced.



zbar = scatstat2(x,y,z,radius)
zbar = scatstat2(x,y,z,radius,fun)


zbar = scatstat2(x,y,z,radius) returns the mean of all z values within specified radius at each point (x,y).

zbar = scatstat2(x,y,z,radius,fun) applies any function fun to z values, default fun is @mean.

Example: Local median

Consider this noisy data set of 5000 scattered points:

N = 5000;
x = randi(750,N,1);
y = randi(750,N,1);
z = sind(x) + cosd(y) + 3*randn(size(x));

axis image off
title 'noisy scattered 2D data'

Take the local median of everything within a radius of 75:

z_median = scatstat2(x,y,z,75,@median);

axis image off
title 'local median'

Author info:

This function was written by Chad A. Greene of the University of Texas at Austin's Institute for Geophysics (UTIG), June 2016.