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.

## Syntax

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

## Description

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)); scatter(x,y,10,z,'filled') 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); scatter(x,y,10,z_median,'filled') 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.