ivan@78
|
1 function x = HardTh(y,thld)
|
ivan@78
|
2 % x = HardTh(y,thld);
|
ivan@78
|
3 %
|
ivan@78
|
4 % HARDTH hard thresholds the input signal y with the threshold value
|
ivan@78
|
5 % thld.
|
ivan@78
|
6 %
|
ivan@78
|
7 % Input:
|
ivan@78
|
8 % y : 1D or 2D signal to be thresholded
|
ivan@78
|
9 % thld : threshold value
|
ivan@78
|
10 %
|
ivan@78
|
11 % Output:
|
ivan@78
|
12 % x : Hard thresholded output (x = (abs(y)>thld).*y)
|
ivan@78
|
13 %
|
ivan@78
|
14 % HERE'S AN EASY WAY TO RUN THE EXAMPLES:
|
ivan@78
|
15 % Cut-and-paste the example you want to run to a new file
|
ivan@78
|
16 % called ex.m, for example. Delete out the % at the beginning
|
ivan@78
|
17 % of each line in ex.m (Can use search-and-replace in your editor
|
ivan@78
|
18 % to replace it with a space). Type 'ex' in matlab and hit return.
|
ivan@78
|
19 %
|
ivan@78
|
20 %
|
ivan@78
|
21 % Example:
|
ivan@78
|
22 % y = makesig('WernerSorrows',8);
|
ivan@78
|
23 % thld = 1;
|
ivan@78
|
24 % x = HardTh(y,thld)
|
ivan@78
|
25 % x = 1.5545 5.3175 0 1.6956 -1.2678 0 1.7332 0
|
ivan@78
|
26 %
|
ivan@78
|
27 % See also: SoftTh
|
ivan@78
|
28 %
|
ivan@78
|
29
|
ivan@78
|
30 %File Name: HardTh.m
|
ivan@78
|
31 %Last Modification Date: 8/15/95 17:49:37
|
ivan@78
|
32 %Current Version: HardTh.m 2.4
|
ivan@78
|
33 %File Creation Date: Mon Jan 31 09:42:50 1994
|
ivan@78
|
34 %Author: Haitao Guo <harry@jazz.rice.edu>
|
ivan@78
|
35 %
|
ivan@78
|
36 %Copyright (c) 2000 RICE UNIVERSITY. All rights reserved.
|
ivan@78
|
37 %Created by Haitao Guo, Department of ECE, Rice University.
|
ivan@78
|
38 %
|
ivan@78
|
39 %This software is distributed and licensed to you on a non-exclusive
|
ivan@78
|
40 %basis, free-of-charge. Redistribution and use in source and binary forms,
|
ivan@78
|
41 %with or without modification, are permitted provided that the following
|
ivan@78
|
42 %conditions are met:
|
ivan@78
|
43 %
|
ivan@78
|
44 %1. Redistribution of source code must retain the above copyright notice,
|
ivan@78
|
45 % this list of conditions and the following disclaimer.
|
ivan@78
|
46 %2. Redistribution in binary form must reproduce the above copyright notice,
|
ivan@78
|
47 % this list of conditions and the following disclaimer in the
|
ivan@78
|
48 % documentation and/or other materials provided with the distribution.
|
ivan@78
|
49 %3. All advertising materials mentioning features or use of this software
|
ivan@78
|
50 % must display the following acknowledgment: This product includes
|
ivan@78
|
51 % software developed by Rice University, Houston, Texas and its contributors.
|
ivan@78
|
52 %4. Neither the name of the University nor the names of its contributors
|
ivan@78
|
53 % may be used to endorse or promote products derived from this software
|
ivan@78
|
54 % without specific prior written permission.
|
ivan@78
|
55 %
|
ivan@78
|
56 %THIS SOFTWARE IS PROVIDED BY WILLIAM MARSH RICE UNIVERSITY, HOUSTON, TEXAS,
|
ivan@78
|
57 %AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
ivan@78
|
58 %BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
ivan@78
|
59 %FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICE UNIVERSITY
|
ivan@78
|
60 %OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
ivan@78
|
61 %EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
ivan@78
|
62 %PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
ivan@78
|
63 %OR BUSINESS INTERRUPTIONS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
ivan@78
|
64 %WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
ivan@78
|
65 %OTHERWISE), PRODUCT LIABILITY, OR OTHERWISE ARISING IN ANY WAY OUT OF THE
|
ivan@78
|
66 %USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
ivan@78
|
67 %
|
ivan@78
|
68 %For information on commercial licenses, contact Rice University's Office of
|
ivan@78
|
69 %Technology Transfer at techtran@rice.edu or (713) 348-6173
|
ivan@78
|
70
|
ivan@78
|
71 x = (abs(y) > thld).*y;
|