⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spatialpattern.m

📁 收集的一组跟噪声产生以及消除、衡量消噪性能指标的MATLAB仿真源代码
💻 M
字号:
From: <由 Microsoft Internet Explorer 5 保存>
Subject: 
Date: Wed, 2 May 2007 13:19:17 +0800
MIME-Version: 1.0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.mathworks.com/matlabcentral/files/5091/spatialPattern.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR></HEAD>
<BODY><PRE>function x =3D spatialPattern(DIM,BETA),
% function x =3D spatialPattern(DIM, BETA),
%
% This function generates 1/f spatial noise, with a normal error=20
% distribution (the grid must be at least 10x10 for the errors to be =
normal).=20
% 1/f noise is scale invariant, there is no spatial scale for which the=20
% variance plateaus out, so the process is non-stationary.
%
%     DIM is a two component vector that sets the size of the spatial =
pattern
%           (DIM=3D[10,5] is a 10x5 spatial grid)
%     BETA defines the spectral distribution.=20
%          Spectral density S(f) =3D N f^BETA
%          (f is the frequency, N is normalisation coeff).
%               BETA =3D 0 is random white noise. =20
%               BETA  -1 is pink noise
%               BETA =3D -2 is Brownian noise
%          The fractal dimension is related to BETA by, D =3D (6+BETA)/2
%=20
% Note that the spatial pattern is periodic.  If this is not wanted the
% grid size should be doubled and only the first quadrant used.
%
% Time series can be generated by setting one component of DIM to 1

% The method is briefly descirbed in Lennon, J.L. "Red-shifts and red
% herrings in geographical ecology", Ecography, Vol. 23, p101-113 (2000)
%
% Many natural systems look very similar to 1/f processes, so generating
% 1/f noise is a useful null model for natural systems.
%
% The errors are normally distributed because of the central
% limit theorem.  The phases of each frequency component are randomly
% assigned with a uniform distribution from 0 to 2*pi. By summing up the
% frequency components the error distribution approaches a normal
% distribution.

% Written by Jon Yearsley  1 May 2004
%     j.yearsley@macaulay.ac.uk
%
% S_f corrected to be S_f =3D (u.^2 + v.^2).^(BETA/2);  2/10/05


% Generate the grid of frequencies. u is the set of frequencies along =
the
% first dimension
% First quadrant are positive frequencies.  Zero frequency is at u(1,1).
u =3D [(0:floor(DIM(1)/2)) -(ceil(DIM(1)/2)-1:-1:1)]'/DIM(1);
% Reproduce these frequencies along ever row
u =3D repmat(u,1,DIM(2));
% v is the set of frequencies along the second dimension.  For a square
% region it will be the transpose of u
v =3D [(0:floor(DIM(2)/2)) -(ceil(DIM(2)/2)-1:-1:1)]/DIM(2);
% Reproduce these frequencies along ever column
v =3D repmat(v,DIM(1),1);

% Generate the power spectrum
S_f =3D (u.^2 + v.^2).^(BETA/2);

% Set any infinities to zero
S_f(S_f=3D=3Dinf) =3D 0;

% Generate a grid of random phase shifts
phi =3D rand(DIM);

% Inverse Fourier transform to obtain the the spatial pattern
x =3D ifft2(S_f.^0.5 .* (cos(2*pi*phi)+i*sin(2*pi*phi)));

% Pick just the real component
x =3D real(x);
</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -