comparison m-toolbox/html_help/help/ug/sigproc_example_matrix_linlsqsvd_content.html @ 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
2
3
4 <p>Determine the coefficients of a linear combination of noises</p>
5
6 <h2>Contents</h2>
7 <div><ul><li><a href="#1">Make data</a></li>
8 <li><a href="#2">Do fit</a></li></ul></div>
9
10 <h2>Make data<a name="1"></a></h2>
11
12 <div class="fragment"><pre>
13
14 fs = 10;
15 nsecs = 10;
16
17 <span class="comment">% fit basis for 2 experiments case</span>
18 B1 = ao(plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>, <span class="string">'fs'</span>, fs, <span class="string">'nsecs'</span>, nsecs, <span class="string">'yunits'</span>, <span class="string">'T'</span>));
19 B1.setName;
20 B2 = ao(plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>, <span class="string">'fs'</span>, fs, <span class="string">'nsecs'</span>, nsecs, <span class="string">'yunits'</span>, <span class="string">'T'</span>));
21 B2.setName;
22 B3 = ao(plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>, <span class="string">'fs'</span>, fs, <span class="string">'nsecs'</span>, nsecs, <span class="string">'yunits'</span>, <span class="string">'T'</span>));
23 B3.setName;
24 B4 = ao(plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>, <span class="string">'fs'</span>, fs, <span class="string">'nsecs'</span>, nsecs, <span class="string">'yunits'</span>, <span class="string">'T'</span>));
25 B4.setName;
26
27 C1 = matrix(B1,B2,plist(<span class="string">'shape'</span>,[2,1]));
28 C1.setName;
29 C2 = matrix(B3,B4,plist(<span class="string">'shape'</span>,[2,1]));
30 C2.setName;
31
32 <span class="comment">% make additive noise</span>
33 n1 = ao(plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>, <span class="string">'fs'</span>, fs, <span class="string">'nsecs'</span>, nsecs, <span class="string">'yunits'</span>, <span class="string">'m'</span>));
34 n1.setName;
35 n2 = ao(plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>, <span class="string">'fs'</span>, fs, <span class="string">'nsecs'</span>, nsecs, <span class="string">'yunits'</span>, <span class="string">'m'</span>));
36 n2.setName;
37
38 <span class="comment">% coefficients of the linear combination</span>
39 a1 = ao(1,plist(<span class="string">'yunits'</span>,<span class="string">'m/T'</span>));
40 a1.setName;
41 a2 = ao(2,plist(<span class="string">'yunits'</span>,<span class="string">'m/T'</span>));
42 a2.setName;
43
44 <span class="comment">% assign output values</span>
45 <span class="comment">% y is a matrix containing the outputs of two experiments:</span>
46 y1 = a1*B1 + a2*B3 + n1;
47 y2 = a1*B2 + a2*B4 + n2;
48 y = matrix(y1,y2,plist(<span class="string">'shape'</span>,[2,1]));
49
50 </pre></div>
51
52
53 </pre><h2>Do fit<a name="2"></a></h2>
54
55 <div class="fragment"><pre>
56
57 <span class="comment">% Get a fit with linlsqsvd</span>
58 pobj = linlsqsvd(C1, C2, y)
59
60 </pre></div>
61
62 <div class="fragment"><pre>
63
64 ---- pest 1 ----
65 name: a1*C1+a2*C2
66 param names: {'a1', 'a2'}
67 y: [0.97312642877028477;2.0892132651873916]
68 dy: [0.06611444020240001;0.065007088662104057]
69 yunits: [T^(-1) m][T^(-1) m]
70 pdf: []
71 cov: [2x2], ([0.00437111920327673 -0.000390118937121542;-0.000390118937121542 0.00422592157632266])
72 corr: []
73 chain: []
74 chi2: 0.85210029717685576
75 dof: 198
76 models: matrix(B1/tsdata Ndata=[100x1], fs=10, nsecs=10, t0=1970-01-01 00:00:00.000 UTC, B2/tsdata Ndata=[100x1], fs=10, nsecs=10, t0=1970-01-01 00:00:00.000 UTC), matrix(B3/tsdata Ndata=[100x1], fs=10, nsecs=10, t0=1970-01-01 00:00:00.000 UTC, B4/tsdata Ndata=[100x1], fs=10, nsecs=10, t0=1970-01-01 00:00:00.000 UTC)
77 description:
78 UUID: 545c9699-e749-40d5-bbe1-1322599c9c5d
79 ----------------
80
81 </pre></div>
82
83 <div class="fragment"><pre>
84
85 <span class="comment">% do linear combination: using eval</span>
86 yfit = pobj.eval;
87
88 <span class="comment">% extract objects</span>
89 yfit1 = getObjectAtIndex(yfit,1);
90 yfit2 = getObjectAtIndex(yfit,2);
91
92 <span class="comment">% Plot - compare data with fit</span>
93 iplot(y1, yfit1)
94 iplot(y2, yfit2)
95
96 </pre></div>
97
98 <p>
99 <div align="center">
100 <IMG src="images/example_matrix_linlsqsvd_01.png" align="center" border="0">
101 </div>
102 </p>
103 <p>
104 <div align="center">
105 <IMG src="images/example_matrix_linlsqsvd_02.png" align="center" border="0">
106 </div>
107 </p>
108