comparison util/Rice Wavelet Toolbox/makesig.m @ 78:f69ae88b8be5

added Rice Wavelet Toolbox with my modification, so it can be compiled on newer systems.
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Fri, 25 Mar 2011 15:27:33 +0000
parents
children
comparison
equal deleted inserted replaced
76:d052ec5b742f 78:f69ae88b8be5
1 function [x,N] = makesig(SigName,N)
2 % [x,N] = makesig(SigName,N) Creates artificial test signal identical to the
3 % standard test signals proposed and used by D. Donoho and I. Johnstone
4 % in WaveLab (- a matlab toolbox developed by Donoho et al. the statistics
5 % department at Stanford University).
6 %
7 % Input: SigName - Name of the desired signal (Default 'all')
8 % 'AllSig' (Returns a matrix with all the signals)
9 % 'HeaviSine'
10 % 'Bumps'
11 % 'Blocks'
12 % 'Doppler'
13 % 'Ramp'
14 % 'Cusp'
15 % 'Sing'
16 % 'HiSine'
17 % 'LoSine'
18 % 'LinChirp'
19 % 'TwoChirp'
20 % 'QuadChirp'
21 % 'MishMash'
22 % 'Werner Sorrows' (Heisenberg)
23 % 'Leopold' (Kronecker)
24 % N - Length in samples of the desired signal (Default 512)
25 %
26 % Output: x - vector/matrix of test signals
27 % N - length of signal returned
28 %
29 % See also:
30 %
31 % References:
32 % WaveLab can be accessed at
33 % www_url: http://playfair.stanford.edu/~wavelab/
34 % Also see various articles by D.L. Donoho et al. at
35 % web_url: http://playfair.stanford.edu/
36
37 %File Name: makesig.m
38 %Last Modification Date: 08/30/95 15:52:03
39 %Current Version: makesig.m 2.4
40 %File Creation Date: Thu Jun 8 10:31:11 1995
41 %Author: Jan Erik Odegard <odegard@ece.rice.edu>
42 %
43 %Copyright (c) 2000 RICE UNIVERSITY. All rights reserved.
44 %Created by Jan Erik Odegard, Department of ECE, Rice University.
45 %
46 %This software is distributed and licensed to you on a non-exclusive
47 %basis, free-of-charge. Redistribution and use in source and binary forms,
48 %with or without modification, are permitted provided that the following
49 %conditions are met:
50 %
51 %1. Redistribution of source code must retain the above copyright notice,
52 % this list of conditions and the following disclaimer.
53 %2. Redistribution in binary form must reproduce the above copyright notice,
54 % this list of conditions and the following disclaimer in the
55 % documentation and/or other materials provided with the distribution.
56 %3. All advertising materials mentioning features or use of this software
57 % must display the following acknowledgment: This product includes
58 % software developed by Rice University, Houston, Texas and its contributors.
59 %4. Neither the name of the University nor the names of its contributors
60 % may be used to endorse or promote products derived from this software
61 % without specific prior written permission.
62 %
63 %THIS SOFTWARE IS PROVIDED BY WILLIAM MARSH RICE UNIVERSITY, HOUSTON, TEXAS,
64 %AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
65 %BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
66 %FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICE UNIVERSITY
67 %OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
68 %EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
69 %PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
70 %OR BUSINESS INTERRUPTIONS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
71 %WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
72 %OTHERWISE), PRODUCT LIABILITY, OR OTHERWISE ARISING IN ANY WAY OUT OF THE
73 %USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74 %
75 %For information on commercial licenses, contact Rice University's Office of
76 %Technology Transfer at techtran@rice.edu or (713) 348-6173
77 %
78 %Change History: This m-file is a copy of the code provided with WaveLab
79 % customized to be consistent with RWT.
80 % Jan Erik Odegard <odegard@ece.rice.edu> Thu Jun 8 1995
81 %
82
83 if(nargin < 1)
84 SigName = 'AllSig';
85 N = 512;
86 elseif(nargin == 1)
87 N = 512;
88 end;
89 t = (1:N) ./N;
90 x = [];
91 y = [];
92 if(strcmp(SigName,'HeaviSine') | strcmp(SigName,'AllSig')),
93 y = 4.*sin(4*pi.*t);
94 y = y - sign(t - .3) - sign(.72 - t);
95 end;
96 x = [x;y];
97 y = [];
98 if(strcmp(SigName,'Bumps') | strcmp(SigName,'AllSig')),
99 pos = [ .1 .13 .15 .23 .25 .40 .44 .65 .76 .78 .81];
100 hgt = [ 4 5 3 4 5 4.2 2.1 4.3 3.1 5.1 4.2];
101 wth = [.005 .005 .006 .01 .01 .03 .01 .01 .005 .008 .005];
102 y = zeros(size(t));
103 for j =1:length(pos)
104 y = y + hgt(j)./( 1 + abs((t - pos(j))./wth(j))).^4;
105 end
106 end;
107 x = [x;y];
108 y = [];
109 if(strcmp(SigName,'Blocks') | strcmp(SigName,'AllSig')),
110 pos = [ .1 .13 .15 .23 .25 .40 .44 .65 .76 .78 .81];
111 hgt = [4 (-5) 3 (-4) 5 (-4.2) 2.1 4.3 (-3.1) 2.1 (-4.2)];
112 y = zeros(size(t));
113 for j=1:length(pos)
114 y = y + (1 + sign(t-pos(j))).*(hgt(j)/2) ;
115 end
116 end;
117 x = [x;y];
118 y = [];
119 if(strcmp(SigName,'Doppler') | strcmp(SigName,'AllSig')),
120 y = sqrt(t.*(1-t)).*sin((2*pi*1.05) ./(t+.05));
121 end;
122 x = [x;y];
123 y = [];
124 if(strcmp(SigName,'Ramp') | strcmp(SigName,'AllSig')),
125 y = t - (t >= .37);
126 end;
127 x = [x;y];
128 y = [];
129 if(strcmp(SigName,'Cusp') | strcmp(SigName,'AllSig')),
130 y = sqrt(abs(t - .37));
131 end;
132 x = [x;y];
133 y = [];
134 if(strcmp(SigName,'Sing') | strcmp(SigName,'AllSig')),
135 k = floor(N * .37);
136 y = 1 ./abs(t - (k+.5)/N);
137 end;
138 x = [x;y];
139 y = [];
140 if(strcmp(SigName,'HiSine') | strcmp(SigName,'AllSig')),
141 y = sin( pi * (N * .6902) .* t);
142 end;
143 x = [x;y];
144 y = [];
145 if(strcmp(SigName,'LoSine') | strcmp(SigName,'AllSig')),
146 y = sin( pi * (N * .3333) .* t);
147 end;
148 x = [x;y];
149 y = [];
150 if(strcmp(SigName,'LinChirp') | strcmp(SigName,'AllSig')),
151 y = sin(pi .* t .* ((N .* .125) .* t));
152 end;
153 x = [x;y];
154 y = [];
155 if(strcmp(SigName,'TwoChirp') | strcmp(SigName,'AllSig')),
156 y = sin(pi .* t .* (N .* t)) + sin((pi/3) .* t .* (N .* t));
157 end;
158 x = [x;y];
159 y = [];
160 if(strcmp(SigName,'QuadChirp') | strcmp(SigName,'AllSig')),
161 y = sin( (pi/3) .* t .* (N .* t.^2));
162 end;
163 x = [x;y];
164 y = [];
165 if(strcmp(SigName,'MishMash') | strcmp(SigName,'AllSig')),
166 % QuadChirp + LinChirp + HiSine
167 y = sin( (pi/3) .* t .* (N .* t.^2)) ;
168 y = y + sin( pi * (N * .6902) .* t);
169 y = y + sin(pi .* t .* (N .* .125 .* t));
170 end;
171 x = [x;y];
172 y = [];
173 if(strcmp(SigName,'WernerSorrows') | strcmp(SigName,'AllSig')),
174 y = sin( pi .* t .* (N/2 .* t.^2)) ;
175 y = y + sin( pi * (N * .6902) .* t);
176 y = y + sin(pi .* t .* (N .* t));
177 pos = [ .1 .13 .15 .23 .25 .40 .44 .65 .76 .78 .81];
178 hgt = [ 4 5 3 4 5 4.2 2.1 4.3 3.1 5.1 4.2];
179 wth = [.005 .005 .006 .01 .01 .03 .01 .01 .005 .008 .005];
180 for j =1:length(pos)
181 y = y + hgt(j)./( 1 + abs((t - pos(j))./wth(j))).^4;
182 end
183 end;
184 x = [x;y];
185 y = [];
186 if(strcmp(SigName,'Leopold') | strcmp(SigName,'AllSig')),
187 y = (t == floor(.37 * N)/N); % Kronecker
188 end;
189 x = [x;y];
190 y = [];
191
192 % disp(sprintf('MakeSignal: I don*t recognize << %s>>',SigName))
193 % disp('Allowable SigNames are:')
194 % disp('AllSig'),
195 % disp('HeaviSine'),
196 % disp('Bumps'),
197 % disp('Blocks'),
198 % disp('Doppler'),
199 % disp('Ramp'),
200 % disp('Cusp'),
201 % disp('Crease'),
202 % disp('Sing'),
203 % disp('HiSine'),
204 % disp('LoSine'),
205 % disp('LinChirp'),
206 % disp('TwoChirp'),
207 % disp('QuadChirp'),
208 % disp('MishMash'),
209 % disp('WernerSorrows'),
210 % disp('Leopold'),
211 %end