0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % MCHNOISEGEN Generates multichannel noise data series given a model
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % FUNCTION: mchNoisegen generates multichannel noise data series given a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % mutichannel noise generating filter.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % DESCRIPTION:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % CALL: out = mchNoisegen(mod, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % INPUT:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % mod: is a matrix containing a multichannel noise generating
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % filter aiming to generate colored noise from unitary variance
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % independent white data series. Each element of the multichannel
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % filter must be a parallel bank of filters as that produced by
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % matrix/mchNoisegenFilter or ao/Noisegen2D. The filter matrix must
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % be square.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % OUTPUT:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % out: is a matrix containg a multichannel colored noise time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % series which csd matrix is defined by mod'*mod.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % HISTORY: 19-10-2009 L Ferraioli
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % Creation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % ------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % <a href="matlab:utils.helper.displayMethodInfo('matrix', 'mchNoisegen')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 % VERSION: $Id: mchNoisegen.m,v 1.6 2011/04/08 08:56:31 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 function varargout = mchNoisegen(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % Check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 % Collect input variable names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 in_names = cell(size(varargin));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 for ii = 1:nargin,in_names{ii} = inputname(ii);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 % Collect all ltpdauoh objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 [mtxs, mtxs_invars] = utils.helper.collect_objects(varargin(:), 'matrix', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 [pl, invars] = utils.helper.collect_objects(varargin(:), 'plist');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 inhists = mtxs.hist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 % combine plists
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 pl = parse(pl, getDefaultPlist());
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 pl.getSetRandState();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 outm = copy(mtxs,nargout);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % Get parameters and set params for fit
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 Nsecs = find(pl, 'nsecs');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 fs = find(pl, 'fs');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 yunit = find(pl, 'yunits');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 % total number of data in the series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 Ntot = round(Nsecs*fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 % chose case for input filter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 if isa(outm,'matrix') && isa(outm.objs(1),'filterbank')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 % discrete system
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 sys = 'z';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 mfil = outm.objs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 [nn,mm] = size(mfil);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 if nn~=mm
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 error('!!! Filter matrix must be square')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 % check if filter is a matrix built with noisegen2D
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 fromnsg2D = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 if nn == 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 nn11 = numel(mfil(1,1).filters);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 nn21 = numel(mfil(2,1).filters);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 if nn11 == nn21
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 % get poles out of the filters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 pl11 = zeros(nn11,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 pl21 = zeros(nn21,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 for ii=1:nn11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 pl11(ii) = -1*mfil(1,1).filters(ii).b(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 pl21(ii) = -1*mfil(2,1).filters(ii).b(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 % check if poles are equal that means they are produced with
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 % noisegen2D
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 if all((pl11-pl21)<eps)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 fromnsg2D = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 elseif isa(outm,'matrix') && isa(outm.objs(1),'parfrac')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 % continuous system
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 sys = 's';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 mfil = outm.objs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 [nn,mm] = size(mfil);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 if nn~=mm
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 error('!!! Filter matrix must be square')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 error('!!! Input filter must be a ''matrix'' of ''filterbank'' or ''parfrac'' objects.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % init output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 out(nn,1) = ao;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 % switch between input filter type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 switch sys
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 case 'z' % discrete input filters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % init output data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 o = zeros(nn,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 for zz=1:nn % moving along system dimension
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 % extract residues and poles from input objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 % run over matrix dimensions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 res = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 pls = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 filtsz = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 for jj=1:nn % collect filters coefficients along the columns zz
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 bfil = mfil(jj,zz).filters;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 filtsz = [filtsz; numel(bfil)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 for kk=1:numel(bfil)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 num = bfil(kk).a;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 den = bfil(kk).b;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 res = [res; num(1)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 pls = [pls; -1*den(2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 % rescaling residues to get the correct result for univariate psd
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 res = res.*sqrt(fs/2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % Nrs = numel(res);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 % % get covariance matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 % R = zeros(Nrs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 % for aa=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 % for bb=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 % R(aa,bb) = (res(aa)*conj(res(bb)))/(1-pls(aa)*conj(pls(bb)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 % % avoiding problems caused by roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 % HH = triu(R,0); % get upper triangular part of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 % HH1 = triu(R,1); % get upper triangular part of R above principal diagonal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 % HH2 = HH1'; % do transpose conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 % R = HH + HH2; % reconstruct R in order to be really hermitian
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 % % get singular value decomposition of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 % [U,S,V] = svd(R,0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 % % conversion matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 % A = V*sqrt(S);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 % % generate unitary variance gaussian random noise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 % %ns = randn(Nrs,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % ns = randn(Nrs,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 % % get correlated starting data points
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 % cns = A*ns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 % % need to correct for roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 % % cleaning up results for numerical approximations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 % idx = imag(pls(:,1))==0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 % cns(idx) = real(cns(idx));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 % % cleaning up results for numerical roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 % % states associated to complex conjugate poles must be complex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 % % conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 % idxi = imag(pls(:,1))~=0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 % icns = cns(idxi);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 % for jj = 1:2:numel(icns)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 % icns(jj+1,1) = conj(icns(jj,1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 % cns(idxi) = icns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 cns = getinitz(res,pls,filtsz,fromnsg2D);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 y = zeros(sum(filtsz),2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 rnoise = zeros(sum(filtsz),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 rns = randn(1,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 %rns = utils.math.blwhitenoise(Ntot,fs,1/Nsecs,fs/2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 %rns = rns.'; % willing to work with raw
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 y(:,1) = cns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 % start recurrence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 for xx = 2:Ntot+1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 rnoise(:,1) = rns(xx-1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 y(:,2) = pls.*y(:,1) + res.*rnoise;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 idxr = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 for kk=1:nn
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 o(kk,xx-1) = o(kk,xx-1) + sum(y(idxr+1:idxr+filtsz(kk),2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 idxr = idxr+filtsz(kk);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 y(:,1) = y(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 clear rns
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 % build output ao
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 for dd=1:nn
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 out(dd,1) = ao(tsdata(o(dd,:),fs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 out(dd,1).setYunits(unit(yunit));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 outm = matrix(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 case 's' % continuous input filters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 o = zeros(nn,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 T = 1/fs; % sampling period
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 for zz=1:nn % moving along system dimension
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 % extract residues and poles from input objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 % run over matrix dimensions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 res = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 pls = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 filtsz = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 for jj=1:nn % collect filters coefficients along the columns zz
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 bfil = mfil(jj,zz);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 filtsz = [filtsz; numel(bfil.res)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 res = [res; bfil.res];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 pls = [pls; bfil.poles];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 % rescaling residues to get the correct result for univariate psd
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 res = res.*sqrt(fs/2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 Nrs = numel(res);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 % get covariance matrix for innovation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 Ri = zeros(Nrs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 for aa=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 for bb=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 Ri(aa,bb) = (res(aa)*conj(res(bb)))*(exp((pls(aa) + conj(pls(bb)))*T)-1)/(pls(aa) + conj(pls(bb)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 % avoiding problems caused by roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 HH = triu(Ri,0); % get upper triangular part of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 HH1 = triu(Ri,1); % get upper triangular part of R above principal diagonal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 HH2 = HH1'; % do transpose conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 Ri = HH + HH2; % reconstruct R in order to be really hermitian
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 % get singular value decomposition of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 [Ui,Si,Vi] = svd(Ri,0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 % conversion matrix for innovation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 Ai = Vi*sqrt(Si);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 % get covariance matrix for initial state
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 Rx = zeros(Nrs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 for aa=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 for bb=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 Rx(aa,bb) = -1*(res(aa)*conj(res(bb)))/(pls(aa) + conj(pls(bb)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 % avoiding problems caused by roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 HH = triu(Rx,0); % get upper triangular part of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 HH1 = triu(Rx,1); % get upper triangular part of R above principal diagonal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 HH2 = HH1'; % do transpose conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 Rx = HH + HH2; % reconstruct R in order to be really hermitian
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 % get singular value decomposition of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 [Ux,Sx,Vx] = svd(Rx,0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 % conversion matrix for initial state
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 Ax = Vx*sqrt(Sx);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 % generate unitary variance gaussian random noise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 %ns = randn(Nrs,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 ns = randn(Nrs,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 % get correlated starting data points
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 cns = Ax*ns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 % need to correct for roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 % cleaning up results for numerical approximations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 idx = imag(pls(:,1))==0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 cns(idx) = real(cns(idx));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 % cleaning up results for numerical roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 % states associated to complex conjugate poles must be complex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 % conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 idxi = imag(pls(:,1))~=0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 icns = cns(idxi);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 for jj = 1:2:numel(icns)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 icns(jj+1,1) = conj(icns(jj,1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 cns(idxi) = icns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 y = zeros(sum(filtsz),2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 rnoise = zeros(sum(filtsz),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 rns = randn(1,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 %rns = utils.math.blwhitenoise(Ntot,fs,1/Nsecs,fs/2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 %rns = rns.'; % willing to work with raw
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 y(:,1) = cns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 % start recurrence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 for xx = 2:Ntot+1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 % innov = Ai*randn(sum(filtsz),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 rnoise(:,1) = rns(xx-1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 innov = Ai*rnoise;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 % need to correct for roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 % cleaning up results for numerical approximations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 innov(idx) = real(innov(idx));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 % cleaning up results for numerical roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 % states associated to complex conjugate poles must be complex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 % conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 iinnov = innov(idxi);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 for jj = 1:2:numel(iinnov)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 iinnov(jj+1,1) = conj(iinnov(jj,1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 innov(idxi) = iinnov;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 y(:,2) = diag(exp(pls.*T))*y(:,1) + innov;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 idxr = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 for kk=1:nn
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 o(kk,xx-1) = o(kk,xx-1) + sum(y(idxr+1:idxr+filtsz(kk),2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 idxr = idxr+filtsz(kk);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 y(:,1) = y(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 % clear rns
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 % build output ao
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 for dd=1:nn
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 out(dd,1) = ao(tsdata(o(dd,:),fs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 out(dd,1).setYunits(unit(yunit));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 outm = matrix(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 % set output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 varargout{1} = outm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 % Get Info Object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 sets = {'Default'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 pl = getDefaultPlist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.sigproc, '$Id: mchNoisegen.m,v 1.6 2011/04/08 08:56:31 hewitson Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 ii.setArgsmin(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 ii.setOutmin(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 ii.setOutmax(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 % Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 function plout = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 persistent pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 if exist('pl', 'var')==0 || isempty(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 pl = buildplist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 plout = pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 function pl = buildplist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 pl = plist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 % Nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 p = param({'nsecs', 'Number of seconds in the desired noise data series.'}, {1, {1}, paramValue.OPTIONAL});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 % Fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 p = param({'fs', 'The sampling frequency of the noise data series.'}, {1, {1}, paramValue.OPTIONAL});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 % Yunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 % Local function
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 % Estimate init values for the z domain case
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 function cns = getinitz(res,pls,filtsz,fromnsg2D)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 if fromnsg2D % init in the case of filters produced with noisegen2D
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 % divide in 2 the problem
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 res1 = res(1:filtsz(1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 res2 = res(filtsz(1)+1:filtsz(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 pls1 = pls(1:filtsz(1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 pls2 = pls(filtsz(1)+1:filtsz(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 %%% the first series %%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 Nrs = numel(res1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 % get covariance matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 R = zeros(Nrs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 for aa=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 for bb=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 R(aa,bb) = (res1(aa)*conj(res1(bb)))/(1-pls1(aa)*conj(pls1(bb)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 % avoiding problems caused by roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 HH = triu(R,0); % get upper triangular part of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 HH1 = triu(R,1); % get upper triangular part of R above principal diagonal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 HH2 = HH1'; % do transpose conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 R = HH + HH2; % reconstruct R in order to be really hermitian
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 % get singular value decomposition of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 [U,S,V] = svd(R,0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 % conversion matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 A = V*sqrt(S);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 % generate unitary variance gaussian random noise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 %ns = randn(Nrs,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 ns = randn(Nrs,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 % get correlated starting data points
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 cns1 = A*ns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 % need to correct for roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 % cleaning up results for numerical approximations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 idx = imag(pls1(:,1))==0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 cns1(idx) = real(cns1(idx));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 % cleaning up results for numerical roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 % states associated to complex conjugate poles must be complex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 % conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 idxi = imag(pls1(:,1))~=0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 icns1 = cns1(idxi);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 for jj = 1:2:numel(icns1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 icns1(jj+1,1) = conj(icns1(jj,1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 cns1(idxi) = icns1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 %%% the second series %%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 Nrs = numel(res2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 % get covariance matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 R = zeros(Nrs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 for aa=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 for bb=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 R(aa,bb) = (res2(aa)*conj(res2(bb)))/(1-pls2(aa)*conj(pls2(bb)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 % avoiding problems caused by roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 HH = triu(R,0); % get upper triangular part of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 HH1 = triu(R,1); % get upper triangular part of R above principal diagonal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 HH2 = HH1'; % do transpose conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 R = HH + HH2; % reconstruct R in order to be really hermitian
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 % get singular value decomposition of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 [U,S,V] = svd(R,0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 % conversion matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 A = V*sqrt(S);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 % generate unitary variance gaussian random noise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 %ns = randn(Nrs,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 ns = randn(Nrs,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 % get correlated starting data points
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 cns2 = A*ns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 % need to correct for roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 % cleaning up results for numerical approximations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 idx = imag(pls2(:,1))==0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 cns2(idx) = real(cns2(idx));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 % cleaning up results for numerical roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 % states associated to complex conjugate poles must be complex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 % conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 idxi = imag(pls2(:,1))~=0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 icns2 = cns2(idxi);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 for jj = 1:2:numel(icns2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 icns2(jj+1,1) = conj(icns2(jj,1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 cns2(idxi) = icns2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 %%% combine results %%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 cns = [cns1;cns2];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 else % init in the case of filters produced with matrix constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 Nrs = numel(res);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 % get covariance matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 R = zeros(Nrs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 for aa=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519 for bb=1:Nrs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 R(aa,bb) = (res(aa)*conj(res(bb)))/(1-pls(aa)*conj(pls(bb)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 % avoiding problems caused by roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 HH = triu(R,0); % get upper triangular part of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 HH1 = triu(R,1); % get upper triangular part of R above principal diagonal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 HH2 = HH1'; % do transpose conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528 R = HH + HH2; % reconstruct R in order to be really hermitian
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 % get singular value decomposition of R
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531 [U,S,V] = svd(R,0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 % conversion matrix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 A = V*sqrt(S);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536 % generate unitary variance gaussian random noise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537 %ns = randn(Nrs,Ntot);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 ns = randn(Nrs,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 % get correlated starting data points
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 cns = A*ns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543 % need to correct for roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 % cleaning up results for numerical approximations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545 idx = imag(pls(:,1))==0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 cns(idx) = real(cns(idx));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 % cleaning up results for numerical roundoff errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549 % states associated to complex conjugate poles must be complex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 % conjugate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551 idxi = imag(pls(:,1))~=0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 icns = cns(idxi);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553 for jj = 1:2:numel(icns)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 icns(jj+1,1) = conj(icns(jj,1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556 cns(idxi) = icns;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560 end
|