www.gusucode.com > wavelet 源码程序 matlab案例代码 > wavelet/SpecifyIntervalsAndThresholdsExample.m

    %% Specify Intervals and Thresholds
% Load the example signal |nbumpr1.mat|. The variance of the additive noise
% differs in three disjoint intervals. 
load nbumpr1.mat;
%% 
% Use a level-5 multiresolution analysis. Create a cell array of length 5 
% consisting of 3-by-3 matrices. The first two elements of each row contain
% the beginning and ending indices of the interval and the last element of 
% each row is the corresponding threshold. 
wname = 'sym4';
level = 5;
sorh = 's';
thrParamsIn =  {...
    [...
    1     207      1.0482; ...
    207   613      2.5110; ...
    613   1024     1.0031; ...
    ]; ...
    [...
    1    207      1.04824; ...
    207  613      3.8718; ...
    613  1024     1.04824; ...
    ]; ...
    [...
    1    207      1.04824; ...
    207  613      1.99710; ...
    613  1024     1.65613; ...
    ]; ...
    [...
    1    207      1.04824; ...
    207  613      2.09117; ...
    613  1024     1.04824; ...
    ]; ...
    [...
    1    207      1.04824; ...
    207  613      1.78620; ...
    613  102      1.04824; ...
    ]; ...
    };
%%
% Denoise the signal using the threshold settings and the Daubechies' 
% least-asymmetric wavelet with 4 vanishing moments. Use a soft 
% thresholding rule. Plot the noisy and denoised signals for comparison.
wname = 'sym4';
level = 5;
sorh = 's';   sigden = cmddenoise(nbumpr1,wname,level,sorh,...
   NaN,thrParamsIn);
plot(nbumpr1); hold on;
plot(sigden,'r','linewidth',2); axis tight;
legend('Noisy Signal','Denoised Signal','Location','NorthEast');