This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

wthresh

Soft or hard thresholding

Syntax

Y = wthresh(X,sorh,T)

Description

example

Y = wthresh(X,sorh,T) returns the soft or hard thresholding, indicated by sorh, of the vector or matrix X. T is the threshold value.

Examples

collapse all

Generate a signal and set a threshold.

y = linspace(-1,1,100);
thr = 0.4;

Perform hard and soft thresholding.

ythard = wthresh(y,'h',thr);
ytsoft = wthresh(y,'s',thr);

Plot the results and compare with the original signal.

subplot(1,3,1)
plot(y,y)
ylim([-1 1])
title('Original Signal')
subplot(1,3,2)
plot(y,ythard)
ylim([-1 1])
title('Hard Threshold')
subplot(1,3,3)
plot(y,ytsoft)
ylim([-1 1])
title('Soft Threshold')

Input Arguments

collapse all

Input data to threshold, specified as a real-valued vector or matrix.

Data Types: double

Type of thresholding to perform:

  • 's' — Soft thresholding

  • 'h' — Hard thresholding

Threshold value, specified as a positive real number.

Output Arguments

collapse all

Thresholded data, returned as a real-valued vector or matrix. Y has the same dimensions as X.

Algorithms

If sorh is 's', Y is the soft thresholding of X: Y=sign(X)·(|X|T)+ where

(x)+={xifx00otherwise

Soft thresholding is wavelet shrinkage.

If sorh is 'h', Y is the hard thresholding of X: Y=X·1(|X|>T) where

1(|X|>T)={1if|X|>T0otherwise

Hard thresholding is cruder than soft thresholding.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a