Mercurial > hg > ltpda
comparison m-toolbox/test/new_plot/test_miplot.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 clear all | |
2 | |
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
5 % TSDATA OBJECTS | |
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
8 %% Make test AOS | |
9 | |
10 p = plist('waveform', 'noise', 'fs', 10, 'nsecs', 10); | |
11 tsao1 = ao(p); | |
12 p = plist('waveform', 'sine wave', 'fs', 10, 'nsecs', 10, 'f', 1, 'phi', 0); | |
13 tsao2 = ao(p); | |
14 | |
15 tsvec = [tsao1 tsao2]; | |
16 tsmat = [tsao1 tsao2; tsao1 tsao2]; | |
17 | |
18 %% Default plot | |
19 miplot(tsao1, tsao2) | |
20 miplot(tsvec) | |
21 miplot(tsmat) | |
22 | |
23 %% Change colors and line styles | |
24 | |
25 pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]); | |
26 miplot(tsao1, tsao2, pl); | |
27 | |
28 %% Change arrangement to single plots | |
29 | |
30 pl = plist('Arrangement', 'single'); | |
31 miplot(tsao1, tsao2, pl); | |
32 | |
33 %% Change arrangement to subplots | |
34 | |
35 % Also override the second legend text and the first line style | |
36 pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'}); | |
37 miplot(tsao1, tsao2, pl); | |
38 | |
39 %% Changel ylabel | |
40 | |
41 % Overide the Y-labels | |
42 pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1', 'signal 2'}, 'Legends', {'', 'My Sine Wave'}); | |
43 miplot(tsao1, tsao2, pl); | |
44 | |
45 %% Changel xlabel | |
46 | |
47 % Overide the X-labels | |
48 pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Time-stamps'}, 'Legends', {'', 'My Sine Wave'}); | |
49 miplot(tsao1, tsao2, pl); | |
50 | |
51 %% No legends | |
52 | |
53 pl = plist('Arrangement', 'subplots', 'Legends', 'off'); | |
54 miplot(tsao1, tsao2, pl); | |
55 | |
56 %% Check math functions | |
57 | |
58 pl = plist('Arrangement', 'subplots', 'YMaths', 'y.^2', 'XMaths', {'', 'log(x)'}); | |
59 miplot(tsao1, tsao2, pl); | |
60 | |
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
63 % FSDATA OBJECTS | |
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
66 | |
67 %% Make test AOs | |
68 | |
69 fsd1 = resp(miir(plist('fs', 100)), plist('f', logspace(-4, log10(50), 1000))); | |
70 fsd1 = set(fsd1, 'yunits', 'm/V'); | |
71 fsd2 = ltpda_pwelch(tsao1+tsao2); | |
72 fsd3 = fsd2*10; | |
73 fsd4 = resp(miir(plist('type', 'highpass'))); | |
74 fsd4 = set(fsd4, 'yunits', 'm/V'); | |
75 | |
76 %% Default plot | |
77 | |
78 miplot(fsd1, fsd2, fsd3, fsd4) | |
79 | |
80 %% Subplots | |
81 | |
82 pl = plist('Arrangement', 'subplots'); | |
83 miplot(fsd1, fsd2, fsd3, fsd4, pl) | |
84 | |
85 %% Single plots | |
86 | |
87 pl = plist('Arrangement', 'single'); | |
88 miplot(fsd1, fsd2, fsd3, fsd4, pl) | |
89 | |
90 %% Use math function on y-data | |
91 | |
92 pl = plist('Ymaths', {'abs(y)'}); | |
93 miplot(fsd1, pl); | |
94 | |
95 %% Change colors and line styles | |
96 | |
97 pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]); | |
98 miplot(fsd1, fsd2, pl); | |
99 | |
100 %% Change arrangement to subplots | |
101 | |
102 % Also override the second legend text and the first line style | |
103 pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'}); | |
104 miplot(fsd1, fsd2, pl); | |
105 | |
106 %% Changel ylabel | |
107 | |
108 % Overide the Y-labels | |
109 pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1 mag', '', 'signal 2'}, 'Legends', {'', 'My Sine Wave'}); | |
110 miplot(fsd1, fsd2, pl); | |
111 | |
112 %% Changel xlabel | |
113 | |
114 % Overide the X-labels | |
115 pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Freq'}, 'Legends', {'', 'My Sine Wave'}); | |
116 miplot(fsd1, fsd2, pl); | |
117 | |
118 %% No legends | |
119 | |
120 pl = plist('Arrangement', 'subplots', 'Legends', 'off'); | |
121 miplot(fsd1, fsd2, pl); | |
122 | |
123 %% Set Y scales | |
124 | |
125 pl = plist('Arrangement', 'subplots', 'YScales', {'', 'log', 'lin'}); | |
126 miplot(fsd1, fsd2, pl); | |
127 | |
128 %% Set X scales | |
129 | |
130 pl = plist('Arrangement', 'subplots', 'XScales', {'', 'lin', 'lin'}); | |
131 miplot(fsd1, fsd2, pl); | |
132 | |
133 %% Set Y ranges | |
134 | |
135 pl = plist('Arrangement', 'subplots', 'YRanges', {[0.1 10], [], [1e-3 100]}); | |
136 miplot(fsd1, fsd2, pl); | |
137 | |
138 | |
139 %% Set X ranges | |
140 | |
141 pl = plist('Arrangement', 'subplots', 'YRanges', [0.001, 10], 'XRanges', {[0.1 10], [0 10], [0.1 10]}); | |
142 miplot(fsd1, fsd2, pl); | |
143 | |
144 | |
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
147 % XYDATA OBJECTS | |
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
150 | |
151 %% Make test AOs | |
152 | |
153 xy1 = ao(xydata(1:100, cos(1:100))); | |
154 xy1 = set(xy1, 'xunits', 'NA', 'yunits', 'NA'); | |
155 xy2 = ao(xydata(1:100, sin(1:100))); | |
156 xy2 = set(xy2, 'xunits', 'NA', 'yunits', 'NA'); | |
157 | |
158 | |
159 %% Default plot | |
160 miplot(xy1, xy2) | |
161 | |
162 %% Use Math function on y-data | |
163 | |
164 pl = plist('Ymaths', {'abs(y)', 'y.^2'}, 'Xmaths', 'log(x)'); | |
165 miplot(xy1, xy2, pl); | |
166 | |
167 | |
168 %% Change colors and line styles | |
169 | |
170 pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]); | |
171 miplot(xy1, xy2, pl); | |
172 | |
173 %% Change arrangement to single plots | |
174 | |
175 pl = plist('Arrangement', 'single'); | |
176 miplot(xy1, xy2, pl); | |
177 | |
178 %% Change arrangement to subplots | |
179 | |
180 % Also override the second legend text and the first line style | |
181 pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'}); | |
182 miplot(xy1, xy2, pl); | |
183 | |
184 %% Changel ylabel | |
185 | |
186 % Overide the Y-labels | |
187 pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1', 'signal 2'}, 'Legends', {'', 'My Sine Wave'}); | |
188 miplot(xy1, xy2, pl); | |
189 | |
190 %% Changel xlabel | |
191 | |
192 % Overide the X-labels | |
193 pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Time-stamps'}, 'Legends', {'', 'My Sine Wave'}); | |
194 miplot(xy1, xy2, pl); | |
195 | |
196 %% No legends | |
197 | |
198 pl = plist('Arrangement', 'subplots', 'Legends', 'off'); | |
199 miplot(xy1, xy2, pl); | |
200 | |
201 | |
202 | |
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
205 % CDATA OBJECTS | |
206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
208 | |
209 | |
210 %% Make test AOS | |
211 | |
212 c1 = ao(randn(1,10)); | |
213 c2 = ao(1:10); | |
214 | |
215 | |
216 %% Default plot | |
217 miplot(c1, c2) | |
218 | |
219 %% Change colors and line styles | |
220 | |
221 pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]); | |
222 miplot(c1, c2, pl); | |
223 | |
224 %% Change arrangement to single plots | |
225 | |
226 pl = plist('Arrangement', 'single'); | |
227 miplot(c1, c2, pl); | |
228 | |
229 %% Change arrangement to subplots | |
230 | |
231 % Also override the second legend text and the first line style | |
232 pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'}); | |
233 miplot(c1, c2, pl); | |
234 | |
235 %% Changel ylabel | |
236 | |
237 % Overide the Y-labels | |
238 pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1', 'signal 2'}, 'Legends', {'', 'My Sine Wave'}); | |
239 miplot(c1, c2, pl); | |
240 | |
241 %% Changel xlabel | |
242 | |
243 % Overide the X-labels | |
244 pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Time-stamps'}, 'Legends', {'', 'My Sine Wave'}); | |
245 miplot(c1, c2, pl); | |
246 | |
247 %% No legends | |
248 | |
249 pl = plist('Arrangement', 'subplots', 'Legends', 'off'); | |
250 miplot(c1, c2, pl); | |
251 | |
252 | |
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
255 % XYZ DATA OBJECTS | |
256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
258 | |
259 %% Test data | |
260 nsecs = 100; | |
261 fs = 100; | |
262 p = plist('waveform', 'noise', 'fs', fs, 'nsecs', nsecs); | |
263 n = ao(p); | |
264 p = plist('waveform', 'chirp', 'fs', fs, 'nsecs', nsecs, 'f0', 0, 'f1', 50, 't1', nsecs); | |
265 s = ao(p); | |
266 | |
267 a = s+n; | |
268 | |
269 % Make spectrogram | |
270 | |
271 sxx = spectrogram(a, plist('Nfft', 4*fs)); | |
272 rxx = spectrogram(s, plist('Nfft', 4*fs)); | |
273 | |
274 %% Plot | |
275 | |
276 pl = plist('Arrangement', 'subplots', 'YMaths', {'log10(y)', 'log10(y)'}, ... | |
277 'Zmaths', {'20*log10(z)', '20*log10(z)'}, ... | |
278 'Xmaths', {'log10(x)'}); | |
279 | |
280 miplot(sxx, rxx, pl) | |
281 | |
282 | |
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
285 % MIXED OBJECTS | |
286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
288 | |
289 %% XY and TSDATA | |
290 miplot(xy1, tsao1, xy2, tsao2, c1) | |
291 |