annotate testing/utp_1.1/utp_test_files/makeTestFiles.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
1 % MAKETESTFILES builds a set of test files for the current LTPDA version.
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
2 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
3 % M Hewitson 09-09-08
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
4 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
5 % $Id: makeTestFiles.m,v 1.8 2010/05/12 15:55:19 ingo Exp $
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
6 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
7 function makeTestFiles()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
8
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
9 mkPlist();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
10
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
11 mkAO();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
12 mkRational();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
13 mkParfrac();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
14 mkPzmodel();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
15 mkMiir();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
16 mkMfir();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
17 mkTimespan();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
18 mkSSM();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
19
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
20 mkCollection();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
21 mkMatrix;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
22 mkSmodel;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
23 mkPest;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
24 mkFilterbank;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
25
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
26 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
27
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
28 %% PLIST
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
29 function mkPlist()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
30
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
31
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
32 pl1 = plist();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
33 pl2 = plist('a', 1, 'b', 2, 'c', 3);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
34 pl3 = plist('char', 'string', ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
35 'number', 123, ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
36 'logical', true, ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
37 'cell', {'asd', [1 2 3; 4 5 6], [true false], 'asd'});
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
38
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
39 pl4 = plist('spec', specwin('kaiser', 5, 20), ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
40 'time', time(123456), ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
41 'ao', ao(1:10, randn(10,1)), ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
42 'miir', miir(plist('type', 'lowpass')));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
43
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
44 plvec = [pl1, pl2, pl3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
45 plmat = [pl1, pl2, pl3; pl4, pl1, pl2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
46
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
47 writeFiles([pl1, pl2, pl3, pl4], plvec, plmat);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
48
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
49 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
50
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
51 %% AO
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
52 function mkAO()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
53
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
54 % tsdata ao
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
55 aots = ao(plist('fs', 10, 'nsecs', 10, ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
56 'tsfcn', 'sin(2*pi*1.4*t) + 0.1*randn(size(t))', ...
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
57 't0', time('1980-12-01 12:43:12')));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
58
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
59 aots.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
60
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
61 % fsdata ao
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
62 aofs = aots.psd;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
63 aofs.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
64
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
65 % xydata ao
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
66 aoxy = ao(xydata(1:10,1:10));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
67 aoxy.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
68
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
69 % cdata ao
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
70 aoc = ao(magic(3));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
71 aoc.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
72
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
73 plvec = [aots, aofs, aoxy];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
74 plmat = [aots, aofs, aoxy; aots, aoc, ao()];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
75
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
76 writeFiles([aots, aofs, aoxy, aoc], plvec, plmat);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
77
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
78 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
79
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
80 %% Pzmodel
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
81 function mkPzmodel()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
82
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
83 pzm1 = pzmodel(1, pz(1), []);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
84 pzm1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
85
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
86 pzm2 = pzmodel(1, [], pz(1));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
87 pzm2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
88
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
89 pzm3 = pzmodel(1, 1, 10);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
90 pzm3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
91
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
92 pzm4 = pzmodel();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
93 pzm4.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
94
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
95 pzm5 = pzmodel(2, 10, {1, [1 1]});
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
96 pzm5.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
97
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
98 pzmvec = [pzm1, pzm2, pzm3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
99 pzmmat = [pzm1, pzm2, pzm3; pzm4, pzm5, pzm5];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
100
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
101 writeFiles([pzm1, pzm2, pzm3, pzm4, pzm5], pzmvec, pzmmat);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
102
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
103 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
104
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
105 %% MFIR
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
106 function mkMfir()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
107
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
108 fir1 = mfir(plist('type', 'highpass'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
109 fir1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
110
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
111 fir2 = mfir(plist('type', 'lowpass'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
112 fir2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
113
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
114 fir3 = mfir(plist('type', 'lowpass', 'fc', .1, 'gain', 1, 'fs', 1, 'order', 64, 'WIN', specwin('Hanning', 65)));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
115 fir3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
116
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
117 pzm = pzmodel(1, [pz(1) pz(200)], pz(50));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
118 pl = plist('pzmodel', pzm, 'fs', 1000);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
119 fir4 = mfir(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
120 fir4.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
121
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
122 a1 = ao(plist('fsfcn', '1./(50+f)', 'f', linspace(0, 500, 1000)));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
123 a1.setFs(1000);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
124 pl = plist('ao', a1);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
125 fir5 = mfir(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
126 fir5.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
127
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
128 firvec = [fir1, fir2, fir3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
129 firmat = [fir1, fir2, fir3; fir4, fir5, fir5];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
130
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
131 writeFiles([fir1, fir2, fir3, fir4, fir5], firvec, firmat);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
132
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
133 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
134 %% MIIR
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
135 function mkMiir()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
136
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
137 iir1 = miir(plist('type', 'lowpass'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
138 iir1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
139
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
140 iir2 = miir(plist('type', 'bandpass', 'fc', [0.01 0.1]));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
141 iir2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
142
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
143 iir3 = miir(plist('type', 'bandreject', 'fc', [0.01 0.1]));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
144 iir3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
145
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
146 pzm = pzmodel(1, [pz(1) pz(200)], pz(50));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
147 pzm.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
148 pl = plist('pzmodel', pzm, 'fs', 1000);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
149 iir4 = miir(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
150 iir4.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
151
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
152 a = [0.5 -0.01];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
153 b = [1 0.1];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
154 fs = 1;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
155 iir5 = miir(a,b,fs);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
156 iir5.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
157
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
158 iirvec = [iir1, iir2, iir3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
159 iirmat = [iir1, iir2, iir3; iir4, iir5, iir5];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
160
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
161 writeFiles([iir1, iir2, iir3, iir4, iir5], iirvec, iirmat);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
162
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
163 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
164
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
165 %% SSM
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
166 function mkSSM
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
167
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
168 try
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
169 s1 = ssm();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
170 s2 = ssm(plist('built-in', 'SMD'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
171 s3 = ssm(plist('built-in', 'HARMONIC_OSC_1D'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
172
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
173 sVec = [s1, s2, s3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
174 sMat = [s1, s2, s3; s2, s1, s2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
175
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
176 writeFiles([s1 s2 s3], sVec, sMat);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
177 catch
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
178 warning('!!! Don''t know how to build this SSM object.');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
179 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
180
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
181 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
182
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
183 %% TIMESPAN
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
184 function mkTimespan()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
185
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
186 ts1 = timespan();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
187 ts1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
188
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
189 ts2 = timespan('2008-08-08 12:00:00', '2008-08-08 13:00:00');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
190 ts2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
191
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
192 ts3 = timespan(time(10), time(100));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
193 ts3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
194
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
195 ts4 = timespan(time(0) ,'14:00:00'); % timespan
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
196 ts4.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
197
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
198 pl = plist('timezone', 'GMT+06','start', time(1234),'end', time(12345));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
199 ts5 = timespan(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
200 ts5.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
201
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
202 tsvec = [ts4, ts2, ts5];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
203
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
204 tsmat = [ts1, ts2, ts5; ts4, ts3, ts2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
205
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
206 writeFiles([ts1, ts2, ts3, ts4, ts5], tsvec, tsmat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
207
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
208 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
209
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
210 %% PARFRAC
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
211 function mkParfrac()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
212
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
213 pf1 = parfrac();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
214 pf1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
215
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
216 pf2 = parfrac([1 2], {4, 6+2i}, []);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
217 pf2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
218
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
219 pf3 = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], [1 2]);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
220 pf3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
221
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
222 pf4 = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], [1 2 3 4], 'my par frac', unit('V'), unit('Hz'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
223 pf4.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
224
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
225 pzm = pzmodel(1, pz(1), [pz(1,2), pz(1+2i)]);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
226 pl = plist('pzmodel', pzm, 'name', 'new name', 'iunits', 'm^3', 'ounits', 'Hz');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
227 pf5 = parfrac(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
228 pf5.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
229
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
230 pfvec = [pf4, pf2, pf5];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
231
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
232 pfmat = [pf1, pf2, pf5; pf4, pf3, pf2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
233
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
234 writeFiles([pf1, pf2, pf3, pf4, pf5], pfvec, pfmat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
235
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
236 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
237
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
238 %% RATIONAL
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
239 function mkRational()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
240
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
241 ra1 = rational();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
242 ra1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
243
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
244 ra2 = rational([1 2], [4, 6], 'my rational');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
245 ra2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
246
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
247 ra3 = rational([1 2 -3], [6 -7 1 -5], 'my par rat', unit('V'), unit('Hz'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
248 ra3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
249
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
250 pzm = pzmodel(1, pz(1), [pz(1,2), pz(1+2i)]);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
251 pl = plist('pzmodel', pzm, 'name', 'new name', 'iunits', 'm^3', 'ounits', 'Hz');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
252 ra4 = rational(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
253 ra4.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
254
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
255 ravec = [ra4, ra3, ra2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
256
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
257 ramat = [ra1, ra2, ra3; ra4, ra3, ra2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
258
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
259 writeFiles([ra1, ra2, ra3, ra4], ravec, ramat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
260
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
261 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
262
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
263 %% COLLECTION
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
264 function mkCollection()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
265
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
266 coll1 = collection();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
267 coll1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
268
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
269 coll2 = collection(rational([1 2], [4, 6], 'my rational'), ao(magic(8)), mfir(plist('type', 'lowpass')));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
270 coll2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
271
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
272 coll3 = collection(ao(1:51, randn(1,51) + 1.1i, 12.3), pzmodel(1, pz(1), [pz(1,2), pz(1+2i)]));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
273 coll3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
274 coll3.setPlotinfo(plist('color', 'black'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
275
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
276
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
277 collVec = [coll1, coll2, coll3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
278
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
279 collMat = [coll3, coll1, coll2; coll2 coll3, coll1];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
280
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
281 writeFiles([coll1, coll2, coll3], collVec, collMat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
282
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
283 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
284
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
285 %% MATRIX
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
286 function mkMatrix()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
287
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
288 m1 = matrix();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
289 m1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
290
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
291 m2 = matrix([ao(1), ao(2) ao(3); ao(4), ao(5), ao(6)]);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
292 m2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
293
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
294 m3 = matrix(ao(1), ao(2), ao(3));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
295 m3.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
296 m3.setPlotinfo(plist('color', 'black'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
297
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
298
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
299 mVec = [m1, m2, m3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
300
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
301 mMat = [m3, m1, m2; m2 m3, m1];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
302
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
303 writeFiles([m1, m2, m3], mVec, mMat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
304
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
305 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
306
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
307 %% SMODEL
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
308 function mkSmodel()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
309
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
310 model1 = smodel();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
311 model1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
312
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
313 model2 = smodel('C1*X1 + C2*X2 + C3*X3');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
314 model2.setParams('C1', 1.00447715161685);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
315 model2.setParams('C2', 2.06131342419899);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
316 model2.setParams('C3', 3.03410245878967);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
317 model2.setXvals(randn(1,100));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
318 % model2.setXvar({'X1', 'X2', 'X3'});
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
319 model2.setXvar('X1');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
320 model2.setXunits(unit('T', 'm', 'C'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
321 model2.setYunits('m');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
322 model2.setPlotinfo(plist('color', 'black'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
323 model2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
324
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
325 modelVec = [model1, model2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
326
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
327 modelMat = [model1, model1 model2; model1 model2, model1];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
328
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
329 writeFiles([model1, model2], modelVec, modelMat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
330
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
331 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
332
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
333 %% PEST
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
334 function mkPest()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
335
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
336 model = smodel('C1*X1 + C2*X2 + C3*X3');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
337 model.setParams('C1', 1.00447715161685);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
338 model.setParams('C2', 2.06131342419899);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
339 model.setParams('C3', 3.03410245878967);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
340 % model.setXvar({'X1', 'X2', 'X3'});
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
341 model.setXvar('X1');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
342 model.setXunits(unit('T', 'm', 'C'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
343 model.setYunits('m');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
344 model.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
345
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
346 pest1 = pest([1;2.06;3.03], {'C1', 'C2', 'C3'}, [0.0917;0.089;0.0957], [0.00841 -0.000604 0.000455;-0.000604 0.00791 -0.000246;0.000455 -0.000246 0.00916]);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
347 pest1.setYunits(unit('[m T^(-1)]','[m m^(-1)]','[m C^(-1)]'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
348 pest1.setModels(model);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
349 pest1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
350
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
351 pest2 = pest();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
352 pest2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
353
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
354 pestVec = [pest1, pest2];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
355
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
356 pestMat = [pest1, pest1 pest2; pest1 pest2, pest1];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
357
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
358 writeFiles([pest1, pest2], pestVec, pestMat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
359
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
360 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
361
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
362 %% FILTERBANK
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
363 function mkFilterbank()
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
364
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
365 a1 = ao(plist('fsfcn', '1./(50+f)', 'f', linspace(0, 500, 1000)));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
366 a1.setFs(1000);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
367 pl = plist('ao', a1);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
368
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
369 f1 = mfir(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
370 f2 = mfir(plist('Type', 'lowpass'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
371 f3 = mfir(plist('type', 'lowpass', 'fc', .1, 'gain', 1, 'fs', 1, 'order', 64, 'WIN', specwin('Hanning', 65)));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
372
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
373 pzm = pzmodel(1, [pz(1) pz(200)], pz(50));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
374 pzm.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
375 pl = plist('pzmodel', pzm, 'fs', 1000);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
376
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
377 f4 = miir(pl);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
378 f5 = miir();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
379 f6 = miir(plist('type', 'bandreject', 'fc', [0.01 0.1]));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
380
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
381 fb1 = filterbank();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
382 fb1.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
383
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
384 fb2 = filterbank([f1, f2, f3], 'serial');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
385 fb2.setPlotinfo(plist('color', 'black'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
386 fb2.setName();
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
387
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
388 fb3 = filterbank(f4, f5, f6);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
389
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
390 fbVec = [fb1, fb2, fb3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
391
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
392 fbMat = [fb1, fb3 fb2; fb1 fb2, fb3];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
393
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
394 writeFiles([fb1, fb2, fb3], fbVec, fbMat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
395
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
396 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
397
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
398 %% Write Function
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
399 function writeFiles(objs, obj_vec, obj_mat)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
400
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
401 % class
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
402 cln = class(objs);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
403
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
404 % Get the toolbox version
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
405 tbxver = getappdata(0, 'ltpda_version');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
406
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
407 % get only the version string without the MATLAB version
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
408 tbxver = strtok(tbxver);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
409
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
410 % remove the points between the subversions
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
411 tbxver = strrep(tbxver, '.', '');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
412
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
413 %%%%%%%%%% Save single objects %%%%%%%%%%
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
414 for ii = 1:numel(objs)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
415
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
416 % Create filename
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
417 filename = sprintf('%s_%s_%d', cln, tbxver, ii);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
418
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
419 % Save XML
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
420 save(objs(ii), [filename '.xml']);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
421 if ~strcmp(tbxver, '191')
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
422 % Save MAT
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
423 save(objs(ii), [filename '.mat']);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
424 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
425 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
426
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
427 %%%%%%%%%% Save vector of object %%%%%%%%%%
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
428
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
429 % Create filename
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
430 filename = sprintf('%s_%s_vec', cln, tbxver);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
431
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
432 % Save XML
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
433 save(obj_vec, [filename '.xml']);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
434 if ~strcmp(tbxver, '191')
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
435 % Save MAT
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
436 save(obj_vec, [filename '.mat']);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
437 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
438
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
439 %%%%%%%%%% Save matrix of object %%%%%%%%%%
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
440
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
441 % Create filename
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
442 filename = sprintf('%s_%s_mat', cln, tbxver);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
443
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
444 % Save XML
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
445 save(obj_mat, [filename '.xml']);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
446 if ~strcmp(tbxver, '191')
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
447 % Save MAT
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
448 save(obj_mat, [filename '.mat']);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
449 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
450
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
451 end