Generate AR1 spatial data

Generates spatial data using an AR1 process with normal error distribution.
Updated 31 Mar 2016

View License

This script generates artificial spatial data using a first order spatial autoregressive process (AR1)
The process is
X(i,j) = PHI*(X(i,j-1)+X(i,j+1)+X(i-1,j)+X(i+1,j) + error

To generate a 10x10, periodic spatial pattern, with normal error distribution, and a variance of SIGMA, the command is


or equivalently,

the same pattern, but with a rigid boundary is generated with


Different error distributions can be used. Using the current script this can be done by extracting the generator matrix, M

M = spatialPatternAR1([10,10],PHI,SIGMA,1,1)

M is a 100x100 matrix.
Then given a random vector, error (size = 100x1) with indepedent elements sampled from the required error distribution, the spatial pattern is given by

x = reshape(M * error,[10,10])

Cite As

Jon Yearsley (2024). Generate AR1 spatial data (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Multivariate Models in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!

Version Published Release Notes

Update for BSD License