声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 4637|回复: 11

[编程技巧] 求助MATLAB中产生高斯色噪声!

[复制链接]
发表于 2009-9-30 15:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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

使用道具 举报

发表于 2009-9-30 18:32 | 显示全部楼层
色噪声?是指有色噪声吗??
 楼主| 发表于 2009-9-30 20:33 | 显示全部楼层
就是高斯色噪声呀,
发表于 2009-10-1 00:24 | 显示全部楼层
看看这些有没用!?
http://www.mathworks.com/matlabcentral/fileexchange/18269
  1. % Function to generate colored noise using Euler-maruyama method
  2. % For measuring,the accuracy of a numerical simulation to an SDE, the
  3. % strong order of convergence is used.
  4. % EM method converges with a strong order =.5

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

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

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

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

  13. function [W,t]= colornoise(a,b,T,N)
  14. randn('state',100);      %fixing the state of generator
  15. dt=T/N;
  16. dW=sqrt(dt)*randn(1,N);

  17. R=4;                      %fixed for this computation
  18. L=N/R;
  19. Xem=zeros(1,L);
  20. Xzero=0;
  21. Xtemp=Xzero;
  22. Dt=R*dt;

  23. for j=1:L
  24.     Winc=sum(dW(R*(j-1)+1:R*j));
  25.     Xtemp=Xtemp+a*Dt*Xtemp+b*Winc;
  26.     Xem(j)=Xtemp;
  27. end

  28. W=[Xzero,Xem];
  29. t=[0:Dt:T]

  30. %plot(t,W)
复制代码

[ 本帖最后由 ChaChing 于 2009-10-1 08:27 编辑 ]
发表于 2009-10-1 00:25 | 显示全部楼层
看看这些有没用!?
http://www.engr.uky.edu/~donohue/ee513/mfiles/MatlabEE513.htm
  1. %  This script generates colored noise by filtering white noise with a
  2. %  Butterworth bandpass filter. Figures are then generated to compare the
  3. %  PSD of the colored noise to the filter transfer function magnitude.  In
  4. %  addition, the autocorrelation is taken of the input white noise sequence
  5. %  and the output colored noise sequence for comparisons.
  6. %
  7. %  Written by Kevin D. Donohue (donohue@engr.uky.edu) March 2004

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

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

  39. %  Compute autocorrelation of output sequence
  40. mxlag = fs*.02;  %  Only compute lags up to 20 milliseconds
  41. [accno, lagcno] = xcorr(cno, mxlag, 'coef');
  42. %  Plot lags
  43. figure(3); plot(1000*lagcno/(fs),accno)
  44. xlabel('milliseconds','Fontsize', 14);  ylabel('Correlation coefficient','Fontsize', 14)
复制代码

评分

1

查看全部评分

 楼主| 发表于 2009-10-1 16:42 | 显示全部楼层
谢谢你!:loveliness: :loveliness:
发表于 2009-10-1 20:38 | 显示全部楼层
没看明白.........
发表于 2009-10-5 22:22 | 显示全部楼层

回复 7楼 flexibility 的帖子

不见得会懂, 但总需要知道那里没看明白?
发表于 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:
发表于 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
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-16 03:33 , Processed in 0.071698 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表