當前位置:編程學習大全網 - 源碼下載 - 用matlab濾除隨機噪聲的算法

用matlab濾除隨機噪聲的算法

% Denoising.m

%

% by Brigitte Forster,

% Centre of Mathematical Sciences

% Munich University of Technology, Germany

%

% Version: March 17 2005

%

% This File shows an example for denoising

% via hard thresholding of Fourier coefficients.

% It is part of the summer term lecture on

% Fourier- and Laplace transform at TUM.

% Threshold festlegen

thresholdstep = 0.01;

% Varianz des normalverteilten Rauschens festlegen

sigma = 3;

% Signal erzeugen

M = 400;

x = -pi:(2*pi/(M-1)):pi;

forig = sin(6*x);

f = forig + sigma*(rand(size(x))-0.5);

figure(1)

subplot(2,2,1)

hold on

plot(x,f)

plot(x, forig,'r-')

axis tight;

hold off

% Fourier-Koeffizienten berechnen

ff = fft(f)/M;

ff = fftshift(ff);

x0 = x/(2*pi)*M;

subplot(2,2,2)

plot(x0,abs(ff),'.','LineWidth', 3)

% Schleife uber verschiedene Thresholds

threshold = 0;

for k = 1:15

threshold = threshold + thresholdstep;

%Fourier-Koeffizienten Thresholden

y = find(abs(ff) < threshold);

ff(y) = 0;

subplot(2,2,3)

plot(x0,abs(ff),'.','LineWidth', 3)

%Inverse Fourier-Transformation

rff = fftshift(ff)*M;

rf = ifft(rff);

subplot(2,2,4)

plot(x, real(rf))

hold on

plot(x, imag(rf),'k')

plot(x, forig,'r')

hold off

axis tight

pause;

end;

  • 上一篇:蘋果手機和安卓手機到底哪個好
  • 下一篇:三人英語小品!急急急!
  • copyright 2024編程學習大全網