peterjiasheng 发表于 2009-9-30 15:44

求助MATLAB中产生高斯色噪声!

我想在MATLAB中产生高斯色噪声,首先用randn产生高斯白噪声,然后通过一个低通滤波器,得到高斯色噪声,我想请问下,在MATLAB中如何实现,希望达人能够指教?

飞飞edifier 发表于 2009-9-30 18:32

色噪声?是指有色噪声吗??

peterjiasheng 发表于 2009-9-30 20:33

就是高斯色噪声呀,

ChaChing 发表于 2009-10-1 00:24

看看这些有没用!?
http://www.mathworks.com/matlabcentral/fileexchange/18269 % Function to generate colored noise using Euler-maruyama method
% For measuring,the accuracy of a numerical simulation to an SDE, the
% strong order of convergence is used.
% EM method converges with a strong order =.5

% Basically to compute the path for color noise we solve the differential
% equation : dx=axdt+bw(t) where w(t) is wiener process
% b defines the intensity of white noise

% Input: a,b (intensity of white noise) and T (the upper limit to time
% vector), N (the no. of samples which essentially defines the step size )
% Output: W(t)( Color noise) ,t (time vector)

% Example colornoise(1,1,1,1000)

% Author : Abhirup lahiri (abhiruplahiri@yahoo.com)

function = colornoise(a,b,T,N)
randn('state',100);      %fixing the state of generator
dt=T/N;
dW=sqrt(dt)*randn(1,N);

R=4;                      %fixed for this computation
L=N/R;
Xem=zeros(1,L);
Xzero=0;
Xtemp=Xzero;
Dt=R*dt;

for j=1:L
    Winc=sum(dW(R*(j-1)+1:R*j));
    Xtemp=Xtemp+a*Dt*Xtemp+b*Winc;
    Xem(j)=Xtemp;
end

W=;
t=

%plot(t,W)


[ 本帖最后由 ChaChing 于 2009-10-1 08:27 编辑 ]

ChaChing 发表于 2009-10-1 00:25

看看这些有没用!?
http://www.engr.uky.edu/~donohue/ee513/mfiles/MatlabEE513.htm
%This script generates colored noise by filtering white noise with a
%Butterworth bandpass filter. Figures are then generated to compare the
%PSD of the colored noise to the filter transfer function magnitude.In
%addition, the autocorrelation is taken of the input white noise sequence
%and the output colored noise sequence for comparisons.
%
%Written by Kevin D. Donohue (donohue@engr.uky.edu) March 2004

fs = 8000;%Sampling Frequency
dur = 20;   %Sound duration in seconds
ord = 6;
plen = 32;% PSD segment length
%Bandlimit on the filter
f1 = ;% lower bandlimit
f2 = ; % corresponding upper bandlimit
% colors for the plots
col = ['g', 'r', 'b', 'k', 'c', 'b'];
no = randn(1,round(fs*dur));%Generate noise signal
= butter(ord,2*/fs);% Generate filter
% perform filter operation to get colored noise
cno = filter(b,a,no);
% Compute the PSD
= pwelch(cno,hamming(plen),fix(plen/2),2*plen, fs); % Compute PSD of noise
figure(1); lh = plot(fax,abs(fs*p/2),col(1)) % Plot PSD
set(lh,'LineWidth',2)%Make line thicker
hold on
%Find filter transfer function
= freqz(b,a,2*plen,fs);
plot(fq,abs(h).^2,col(2))
hold off
% Label figure
xlabel('Hertz', 'Fontsize', 14)
ylabel('PSD', 'Fontsize', 14)

%Compute autocorrelation of input sequence
mxlag = fs*.02;%Only compute lags up to 20 milliseconds
= xcorr(no, mxlag, 'coef');
%Plot lags
figure(2); plot(1000*lagwno/(fs),acwno)
xlabel('milliseconds','Fontsize', 14);ylabel('Correlation coefficient','Fontsize', 14)

%Compute autocorrelation of output sequence
mxlag = fs*.02;%Only compute lags up to 20 milliseconds
= xcorr(cno, mxlag, 'coef');
%Plot lags
figure(3); plot(1000*lagcno/(fs),accno)
xlabel('milliseconds','Fontsize', 14);ylabel('Correlation coefficient','Fontsize', 14)

peterjiasheng 发表于 2009-10-1 16:42

谢谢你!:loveliness: :loveliness:

flexibility 发表于 2009-10-1 20:38

没看明白.........

ChaChing 发表于 2009-10-5 22:22

回复 7楼 flexibility 的帖子

不见得会懂, 但总需要知道那里没看明白?

guaiguaigui 发表于 2010-8-5 16:57

非常感谢啊

熊星星星 发表于 2012-3-9 21:34

参数a是??
参数b是指高斯白噪声的信噪比吗??

熊星星星 发表于 2012-3-9 22:11

Function to generate colored noise using Euler-maruyama method
为什么用不了?Attempt to execute SCRIPT colornoise as a function:

ChaChing 发表于 2012-3-13 00:13

本帖最后由 ChaChing 于 2012-3-13 00:14 编辑

回复 11 # 熊星星星 的帖子

Ref: 常见的程序出错问题整理 http://forum.vibunion.com/thread-46001-1-1.html
   6F->Attempt to execute SCRIPT conv as a function
From http://forum.vibunion.com/home-space-uid-63979-do-blog-id-18250.html
页: [1]
查看完整版本: 求助MATLAB中产生高斯色噪声!