0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % CB_ADDSIGNAL callback fires when the user clicks 'add signal'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % M Hewitson
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % $Id: cb_addSignal.m,v 1.1 2008/10/19 11:42:40 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 function cb_addSignal(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 myh = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 mainfig = varargin{end};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % sigType handle
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 sh = findobj(mainfig.handle, 'Tag', 'SignalTypeSelect');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % Get selected signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 val = get(sh, 'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 sigs = get(sh, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 sig = sigs{val};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % Build signals
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 switch lower(sig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 case 'sine wave'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 obj = buildSineWave(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 case 'white noise'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 obj = buildWhiteNoise(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 case 'chirp'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 obj = buildChirp(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 case 'gaussian pulse'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 obj = buildGaussPulse(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 case 'square wave'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 obj = buildSquarewave(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 case 'sawtooth'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 obj = buildSawtooth(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 case 'noise generator'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 obj = buildNoiseGen(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 case 'polynomial'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 obj = buildPolynomial(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 case 'custom'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 obj = buildCustom(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 error('### I can''t build signal ''%s'' yet', sig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 % Add this AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 mainfig.signals = [mainfig.signals obj];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % Refresh list
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 refreshSignalList(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % Build a noisegenerator signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 function obj = buildPolynomial(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 % get coeffs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 h = findobj(mainfig.handle, 'Tag', 'Poly_Coeffs');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 coeffs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 if isempty(name) || strcmpi(name, 'none')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 name = sprintf('poly(%s)', mat2str(coeffs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 h = findobj(mainfig.handle, 'Tag', 'Poly_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 obj = ao(plist('polyval', coeffs, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 % Build a noisegenerator signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 function obj = buildNoiseGen(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 % get f0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 h = findobj(mainfig.handle, 'Tag', 'NoiseGen_Gain');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 g = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 % get poles
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 h = findobj(mainfig.handle, 'Tag', 'NoiseGen_Poles');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 poles = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 % get zeroes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 h = findobj(mainfig.handle, 'Tag', 'NoiseGen_Zeros');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 zeros = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 if isempty(name) || strcmpi(name, 'none')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 name = sprintf('noisegen');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 h = findobj(mainfig.handle, 'Tag', 'NoiseGen_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 pzm = pzmodel(g, poles, zeros);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 obj = ao(plist('pzmodel', pzm, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 % Build a sawtooth signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 function obj = buildSawtooth(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 % get f0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 h = findobj(mainfig.handle, 'Tag', 'Sawtooth_F');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 f0 = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 % get duty
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 h = findobj(mainfig.handle, 'Tag', 'Sawtooth_Width');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 wd = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 if isempty(name) || strcmpi(name, 'none')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 name = sprintf('saw(%g)', f0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 h = findobj(mainfig.handle, 'Tag', 'Sawtooth_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 obj = ao(plist('waveform', 'Sawtooth', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 'f0', f0, 'width', wd, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 % Build a square wave signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 function obj = buildSquarewave(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 % get f0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 h = findobj(mainfig.handle, 'Tag', 'SquareWave_F');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 f0 = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 % get duty
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 h = findobj(mainfig.handle, 'Tag', 'SquareWave_Duty');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 duty = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 if isempty(name) || strcmpi(name, 'none')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 name = sprintf('square(%g)', f0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 h = findobj(mainfig.handle, 'Tag', 'SquareWave_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 obj = ao(plist('waveform', 'Square wave', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 'f0', f0, 'duty', duty, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 % Build a gauss pulse signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 function obj = buildGaussPulse(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 % get f0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 h = findobj(mainfig.handle, 'Tag', 'GPulse_F0');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 f0 = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 % get BW
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 h = findobj(mainfig.handle, 'Tag', 'GPulse_BW');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 bw = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 if isempty(name) || strcmpi(name, 'none')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 name = sprintf('gpulse(%g)', f0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 h = findobj(mainfig.handle, 'Tag', 'GPulse_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 obj = ao(plist('waveform', 'Gaussian pulse', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 'f0', f0, 'bw', bw, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 % Build a chirp signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 function obj = buildChirp(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 % get f0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 h = findobj(mainfig.handle, 'Tag', 'Chirp_F0');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 f0 = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 % get f1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 h = findobj(mainfig.handle, 'Tag', 'Chirp_F1');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 f1 = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 if isempty(name) || strcmpi(name, 'none')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 name = sprintf('chirp(%g->%g)', f0,f1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 % get T1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 h = findobj(mainfig.handle, 'Tag', 'Chirp_T1');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 t1 = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 h = findobj(mainfig.handle, 'Tag', 'Chirp_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 obj = ao(plist('waveform', 'chirp', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 'f0', f0, 'f1', f1, 't1', t1, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 % Build a custom signal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 function obj = buildCustom(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 % get type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 h = findobj(mainfig.handle, 'Tag', 'Custom_Fcn');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 fcn = get(h, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 if isempty(name) || strcmpi(name, 'none')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 name = fcn;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 h = findobj(mainfig.handle, 'Tag', 'Custom_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 obj = ao(plist('tsfcn', fcn, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 % Build a white noise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 function obj = buildWhiteNoise(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 % get type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 h = findobj(mainfig.handle, 'Tag', 'WhiteNoise_Type');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 types = get(h, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 type = types{get(h, 'Value')};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 if strcmpi(name, 'none') || isempty(name)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 name = type;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 % get Sigma
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 h = findobj(mainfig.handle, 'Tag', 'WhiteNoise_Sigma');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 sigma = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 h = findobj(mainfig.handle, 'Tag', 'WhiteNoise_Length');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 obj = ao(plist('waveform', 'noise', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 'type', type, 'sigma', sigma, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 'nsecs', Nsecs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 % Build a sine wave
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 function obj = buildSineWave(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 [fs, t0, name] = getFsT0(mainfig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 % get amplitudes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 h = findobj(mainfig.handle, 'Tag', 'SineWave_Amplitudes');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 amps = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 % get frequencies
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 h = findobj(mainfig.handle, 'Tag', 'SineWave_Frequencies');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 freqs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 % get phases
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 h = findobj(mainfig.handle, 'Tag', 'SineWave_Phases');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 phases = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 % get Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 h = findobj(mainfig.handle, 'Tag', 'SineWave_Lengths');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 Nsecs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 % get Toffs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 h = findobj(mainfig.handle, 'Tag', 'SineWave_Starts');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 Toffs = eval(['[' get(h, 'String') ']']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 if strcmpi(name, 'none') || isempty(name)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 name = 'sin(';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 name = [name sprintf('%.2g,', freqs)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 name = [name(1:end-1) ')'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 % Build
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 obj = ao(plist('waveform', 'sine wave', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 'A', amps, 'f', freqs, 'phi', phases*pi/180, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 'nsecs', Nsecs, 'toff', Toffs, 'fs', fs, 't0', t0, 'name', name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 % Retrieve the sample rate and start time and name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 function [fs, t0, name] = getFsT0(mainfig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 % name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 h = findobj(mainfig.handle, 'Tag', 'NameEdit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 name = get(h, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 % T0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 h = findobj(mainfig.handle, 'Tag', 'T0edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 t0 = time(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 % FS
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 h = findobj(mainfig.handle, 'Tag', 'SampleRateEdit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 fs = eval(get(h, 'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295
|