Mercurial > hg > ltpda
comparison m-toolbox/classes/@matrix/linfitsvd.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % LINFITSVD Linear fit with singular value decomposition | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Linear least square problem with singular value | |
5 % decomposition | |
6 % | |
7 % ALGORITHM: Perform linear identification of the parameters of a | |
8 % multichannel systems. The results of different experiments on the same | |
9 % system can be passed as input. The algorithm, thanks to the singular | |
10 % value decomposition, extract the maximum amount of information from each | |
11 % single channel and for each experiment. Total information is then | |
12 % combined to get the final result. | |
13 % | |
14 % CALL: pars = linfitsvd(os1,...,osn,pl); | |
15 % | |
16 % INPUT: | |
17 % - osi are vector of system output signals. They must be | |
18 % Nx1 matrix objects, where N is the output dimension of the | |
19 % system | |
20 % | |
21 % OUTPUT: | |
22 % - pars: a pest object containing parameter estimation | |
23 % | |
24 % <a href="matlab:utils.helper.displayMethodInfo('matrix', 'linfitsvd')">Parameters Description</a> | |
25 % | |
26 % VERSION: $Id: linfitsvd.m,v 1.38 2011/04/08 08:56:32 hewitson Exp $ | |
27 % | |
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
29 | |
30 function varargout = linfitsvd(varargin) | |
31 | |
32 %%% LTPDA stufs and get data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
33 | |
34 % Check if this is a call for parameters | |
35 if utils.helper.isinfocall(varargin{:}) | |
36 varargout{1} = getInfo(varargin{3}); | |
37 return | |
38 end | |
39 | |
40 import utils.const.* | |
41 utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename); | |
42 | |
43 % Collect input variable names | |
44 in_names = cell(size(varargin)); | |
45 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
46 | |
47 % Collect all ltpdauoh objects | |
48 [mtxs, mtxs_invars] = utils.helper.collect_objects(varargin(:), 'matrix', in_names); | |
49 [pl, invars] = utils.helper.collect_objects(varargin(:), 'plist'); | |
50 | |
51 inhists = [mtxs(:).hist]; | |
52 | |
53 % combine plists | |
54 pl = parse(pl, getDefaultPlist()); | |
55 | |
56 %%% get input parameters | |
57 % if the model is a matrix of smodels | |
58 lmod = find(pl, 'dmodel'); | |
59 % if the model is ssm | |
60 inNames = find(pl,'InNames'); | |
61 outNames = find(pl,'OutNames'); | |
62 % common parameters | |
63 mod = find(pl,'Model'); | |
64 fitparams = find(pl,'FitParams'); | |
65 inputdat = find(pl,'Input'); | |
66 WF = find(pl,'WhiteningFilter'); | |
67 nloops = find(pl,'Nloops'); | |
68 ncut = find(pl,'Ncut'); | |
69 npad = find(pl,'Npad'); | |
70 kwnpars = find(pl,'KnownParams'); | |
71 tol = find(pl,'tol'); | |
72 fastopt = find(pl,'fast'); | |
73 setalias = find(pl,'SetAlias'); | |
74 sThreshold = find(pl,'sThreshold'); | |
75 diffStep = find(pl,'diffStep'); | |
76 | |
77 boundedpars = find(pl,'BoundedParams'); | |
78 boudary = find(pl,'BoundVals'); | |
79 | |
80 % check if there are bounded parameters | |
81 if ~isempty(boundedpars) | |
82 boundparams = true; | |
83 else | |
84 boundparams = false; | |
85 end | |
86 | |
87 | |
88 % check the class of the model | |
89 if isa(mod,'ssm') | |
90 ssmmod = true; | |
91 else | |
92 ssmmod = false; | |
93 end | |
94 | |
95 %%% some sanity checks | |
96 if ~ssmmod | |
97 if numel(mtxs)~= numel(inputdat.objs) | |
98 error('Number of input data vectors must be the same of fit data vectors') | |
99 end | |
100 end | |
101 | |
102 | |
103 [fitparams,idx] = sort(fitparams); | |
104 fitparvals = fitparams; | |
105 if ssmmod | |
106 %%% get fit parameters | |
107 for ii=1:numel(fitparams) | |
108 fitparvals{ii} = mod.getParameters(plist('names',fitparams{ii})); | |
109 end | |
110 if isempty(diffStep) | |
111 sdiffStep = cell2mat(fitparvals).*0.01; | |
112 idz = sdiffStep == 0; | |
113 sdiffStep(idz) = 1e-7; | |
114 else | |
115 sdiffStep = diffStep(idx); | |
116 end | |
117 else | |
118 %%% get a single set of parameters | |
119 totparnames = {}; | |
120 totparvals = {}; | |
121 for ii=1:numel(mod.objs) | |
122 aa = mod.objs(ii).params; | |
123 cc = mod.objs(ii).values; | |
124 % get total parameter names | |
125 [bb,i1,i2]=union(totparnames,aa); | |
126 totparnames = [totparnames(i1),aa(i2)]; | |
127 % get total parameter values | |
128 totparvals = [totparvals(i1),cc(i2)]; | |
129 end | |
130 [totparnames,id] = sort(totparnames); | |
131 totparvals = totparvals(id); | |
132 | |
133 %%% get fit parameters | |
134 [nn,i1,i2] = intersect(totparnames,fitparams); | |
135 fitparams = totparnames(i1); | |
136 fitparvals = totparvals(i1); | |
137 [fitparams,id] = sort(fitparams); | |
138 fitparvals = fitparvals(id); | |
139 end | |
140 | |
141 if ~ssmmod | |
142 %%% linearize model with respect to fit parameters | |
143 if isempty(lmod) | |
144 lmod = linearize(mod,plist('Params',fitparams,'Sorting',false)); | |
145 end | |
146 end | |
147 | |
148 if isempty(WF) | |
149 wfdat = copy(mtxs,1); | |
150 elseif ~fastopt | |
151 %%% whitening fit data | |
152 wfdat = copy(mtxs,1); | |
153 for ii=1:numel(mtxs) | |
154 wfdat(ii) = filter(mtxs(ii),WF); | |
155 end | |
156 end | |
157 | |
158 % decide to pad in any case, assuming the objects have the same length | |
159 if isempty(npad) | |
160 npad = length(mtxs(1).objs(1).data.y) - 1; | |
161 end | |
162 | |
163 % set alias if there are | |
164 if setalias && (~ssmmod && ~isempty(mod.objs(1).aliasNames)) | |
165 nsecs = mtxs(1).objs(1).data.nsecs; | |
166 fs = mtxs(1).objs(1).data.fs; | |
167 | |
168 plalias = plist('nsecs',nsecs,'npad',npad,'fs',fs); | |
169 for ii=1:numel(mod.objs) | |
170 mod.objs(ii).assignalias(mod.objs(ii),plalias); | |
171 end | |
172 for jj=1:numel(lmod.objs) | |
173 for ii=1:numel(lmod.objs{jj}.objs) | |
174 lmod.objs{jj}.objs(ii).assignalias(lmod.objs{jj}.objs(ii),plalias); | |
175 end | |
176 end | |
177 end | |
178 | |
179 % do a copy to add at the output pest | |
180 outmod = copy(mod,1); | |
181 | |
182 % check if the fast option is active | |
183 if ~ssmmod && fastopt | |
184 % set length of fft (this should match the operation made in fftfilt_core) | |
185 nfft = length(mtxs(1).objs(1).data.y) + npad; | |
186 fs = mtxs(1).objs(1).data.fs; | |
187 % get fft freqs for current data. type option must match the one used | |
188 % in fftfilt_core for fft_core | |
189 fftfreq = utils.math.getfftfreq(nfft,fs,'one'); | |
190 % calculate freq resp of diagonal elements of WF | |
191 rWF = getWFresp(WF,fftfreq,fs); | |
192 % combine symbolic models with rWF | |
193 mod = joinmodelandfilter(mod,rWF); | |
194 lmod = joinmodelandfilter(lmod,rWF); | |
195 WF = []; | |
196 %%% whitening fit data | |
197 wfdat = copy(mtxs,1); | |
198 for ii=1:numel(mtxs) | |
199 for jj=1:numel(mtxs(ii).objs) | |
200 wfdat(ii).objs(jj) = fftfilt_core(wfdat(ii).objs(jj),rWF.objs(jj),npad); | |
201 end | |
202 end | |
203 clear rWF | |
204 end | |
205 | |
206 % init storage struct | |
207 loop_results = struct('a',cell(1),... | |
208 'Ca',cell(1),... | |
209 'Corra',cell(1),... | |
210 'Vu',cell(1),... | |
211 'bu',cell(1),... | |
212 'Cbu',cell(1),... | |
213 'Fbu',cell(1),... | |
214 'mse',cell(1),... | |
215 'params',cell(1),... | |
216 'ppm',cell(1)); | |
217 | |
218 % init user interaction variable | |
219 reply = 'N'; | |
220 | |
221 %%% run fit loop | |
222 | |
223 % This causes problems on some machines so we remove it for now until we | |
224 % can investigate further. | |
225 % fftw('planner', 'exhaustive'); | |
226 | |
227 for kk=1:nloops | |
228 | |
229 % init index variable | |
230 xxx = 1; | |
231 | |
232 % init data struct | |
233 exps = struct(); | |
234 | |
235 %%% Set fit parameters into model | |
236 if ssmmod | |
237 fs = wfdat(1).objs(1).fs; | |
238 mod.doSetParameters(fitparams,cell2mat(fitparvals)); | |
239 lmod = parameterDiff(mod,plist('names',fitparams,'values',sdiffStep)); | |
240 lmod.modifyTimeStep(plist('newtimestep',1/fs)); | |
241 else | |
242 % fitparvals are updated at each fit loop | |
243 if fastopt | |
244 for ii = 1:numel(mod.objs) | |
245 mod.objs(ii).objs{2}.setParams(fitparams,fitparvals); | |
246 end | |
247 else | |
248 for ii = 1:numel(mod.objs) | |
249 mod.objs(ii).setParams(fitparams,fitparvals); | |
250 end | |
251 end | |
252 end | |
253 | |
254 %%% run over input data | |
255 | |
256 for ii=1:numel(inputdat.objs) | |
257 if ssmmod | |
258 %%% extract input | |
259 if isa(inputdat.objs{ii},'ao') | |
260 in = inputdat.objs{ii}; | |
261 elseif isa(inputdat.objs{ii},'matrix') | |
262 in = inputdat.objs{ii}.objs(:); | |
263 else | |
264 error('Unknown Input data type.') | |
265 end | |
266 | |
267 %%% calculates zero order response | |
268 plsym = plist('AOS VARIABLE NAMES',inNames{ii},... | |
269 'RETURN OUTPUTS',outNames{ii},... | |
270 'AOS',in); | |
271 %eo = simulate(lmod,plsym); | |
272 %zor = matrix(eo,plist('shape',[numel(eo) 1])); | |
273 zor = simulate(lmod,plsym); | |
274 % check dimensions | |
275 if size(zor.objs,1)<size(zor.objs,2) | |
276 % do transpose | |
277 zor = transpose(zor); | |
278 end | |
279 | |
280 %%% calculates first order response | |
281 for jj=1:numel(fitparams) | |
282 % get output ports names | |
283 [token, remain] = strtok(outNames{ii},'.'); | |
284 loutNames = token; | |
285 for zz=1:numel(token) | |
286 loutNames{zz} = sprintf('%s_DIFF_%s%s',token{zz},fitparams{jj},remain{zz}); | |
287 end | |
288 plsym = plist('AOS VARIABLE NAMES',inNames{ii},... | |
289 'RETURN OUTPUTS',loutNames,... | |
290 'AOS',in); | |
291 %eol = simulate(lmod,plsym); | |
292 %fstor(jj) = matrix(eol,plist('shape',[numel(eol) 1])); | |
293 fstor(jj) = simulate(lmod,plsym); | |
294 % check dimensions | |
295 if size(fstor(jj).objs,1)<size(fstor(jj).objs,2) | |
296 % do transpose | |
297 fstor(jj) = transpose(fstor(jj)); | |
298 end | |
299 fstor(jj).setName(fitparams{jj}); | |
300 end | |
301 else | |
302 %%% calculates zero order response | |
303 zor = fftfilt(inputdat.objs{ii},mod,plist('Npad',npad)); | |
304 | |
305 %%% calculates first order response | |
306 for jj=1:numel(lmod.objs) | |
307 fstor(jj) = fftfilt(inputdat.objs{ii},lmod.objs{jj},plist('Npad',npad)); | |
308 fstor(jj).setName(lmod.objs{jj}.name); | |
309 end | |
310 end | |
311 | |
312 if isempty(WF) | |
313 wzor = zor; | |
314 wfstor = fstor; | |
315 else | |
316 %%% whitening zor | |
317 wzor = filter(zor,WF); | |
318 | |
319 %%% whitening fstor | |
320 for jj=1:numel(fstor) | |
321 wfstor(jj) = filter(fstor(jj),WF); | |
322 wfstor(jj).setName(fstor(jj).name); | |
323 end | |
324 end | |
325 | |
326 %%% Collect object for the fit procedure | |
327 for jj=1:numel(wfdat(ii).objs) | |
328 % get difference between fit data and zero order response | |
329 tfdat = wfdat(ii).objs(jj) - wzor.objs(jj); | |
330 % remove whitening filter transient | |
331 tfdats = tfdat.split(plist('samples',[ncut+1 numel(tfdat.y)])); | |
332 % insert into exps struct | |
333 fitdata(xxx,1) = tfdats; | |
334 | |
335 % build fit basis | |
336 for gg=1:numel(fitparams) | |
337 for hh=1:numel(wfstor) | |
338 if strcmp(fitparams(gg),wfstor(hh).name) | |
339 bsel = wfstor(hh).objs(jj); | |
340 % remove whitening filter transient | |
341 bsels = bsel.split(plist('samples',[ncut+1 numel(tfdat.y)])); | |
342 end | |
343 end | |
344 bs(gg) = bsels; | |
345 end | |
346 % insert basis | |
347 fitbasis(xxx,:) = bs; | |
348 | |
349 % step up xxx | |
350 xxx = xxx + 1; | |
351 end %jj=1:numel(wfdat(ii).objs) | |
352 | |
353 end %ii=1:numel(inputdat.objs) | |
354 | |
355 %%% build input objects | |
356 [NN,MM] = size(fitbasis); | |
357 | |
358 for zz=1:MM | |
359 H(1,zz) = matrix(fitbasis(:,zz)); | |
360 end | |
361 | |
362 Y = matrix(fitdata); | |
363 | |
364 %%% Insert known parameters | |
365 if ~isempty(kwnpars) | |
366 kwnparmanes = kwnpars.names; | |
367 kwnparvals = kwnpars.y; | |
368 kwnparerrors = kwnpars.dy; | |
369 | |
370 % init struct | |
371 groundexps = struct; | |
372 | |
373 for ii=1:numel(kwnparmanes) | |
374 for jj=1:numel(fitparams) | |
375 if strcmp(kwnparmanes{ii},fitparams{jj}) | |
376 groundexps(ii).pos = jj; | |
377 groundexps(ii).value = kwnparvals(ii); | |
378 groundexps(ii).err = kwnparerrors(ii); | |
379 end | |
380 end | |
381 end | |
382 end | |
383 | |
384 | |
385 %%% do fit | |
386 if ~isempty(kwnpars) && isfield(groundexps,'pos') | |
387 plfit = plist('KnownParams',groundexps,'sThreshold',sThreshold); | |
388 [out,a,Ca,Corra,Vu,bu,Cbu,Fbu,mse,dof,ppm] = linlsqsvd(H,Y,plfit); | |
389 else | |
390 plfit = plist('sThreshold',sThreshold); | |
391 [out,a,Ca,Corra,Vu,bu,Cbu,Fbu,mse,dof,ppm] = linlsqsvd(H,Y,plfit); | |
392 end | |
393 | |
394 %%% update parameters values | |
395 for ii=1:numel(fitparams) | |
396 fitparvals{ii} = fitparvals{ii} + a(ii); | |
397 end | |
398 | |
399 %%% check for bouded params | |
400 if boundparams | |
401 for pp=1:numel(fitparams) | |
402 for qq=1:numel(boundedpars) | |
403 if strcmp(fitparams{pp},boundedpars{qq}); | |
404 % check boudaries | |
405 bd = boudary{qq}; | |
406 if fitparvals{pp}<bd(1) | |
407 fitparvals{pp} = bd(1); | |
408 elseif fitparvals{pp}>bd(2) | |
409 fitparvals{pp} = bd(2); | |
410 end | |
411 end | |
412 end | |
413 end | |
414 end | |
415 | |
416 %%% store intermediate results | |
417 loop_results(kk).a = a; | |
418 loop_results(kk).Ca = Ca; | |
419 loop_results(kk).Corra = Corra; | |
420 loop_results(kk).Vu = Vu; | |
421 loop_results(kk).bu = bu; | |
422 loop_results(kk).Cbu = Cbu; | |
423 loop_results(kk).Fbu = Fbu; | |
424 loop_results(kk).mse = mse; | |
425 loop_results(kk).params = fitparvals; | |
426 loop_results(kk).ppm = ppm; | |
427 | |
428 utils.helper.msg(msg.IMPORTANT, 'loop %d, mse %d\n',kk,mse); | |
429 | |
430 % check fit stability and accuracy | |
431 fitmsg = checkfit(Vu,a); | |
432 if ~isempty(fitmsg) && ~strcmpi(reply,'Y') | |
433 % display message | |
434 utils.helper.msg(msg.IMPORTANT, fitmsg); | |
435 % decide if stop for cycle | |
436 reply = input('Do you want to carry on with fit iteration? Y/N [Y]: ', 's'); | |
437 if isempty(reply) | |
438 reply = 'Y'; | |
439 end | |
440 if strcmpi(reply,'N') | |
441 break | |
442 end | |
443 end | |
444 | |
445 % check convergence | |
446 condvec = (abs(a).^2)./diag(Ca); % parameters a are going to zero during the fit iterations | |
447 | |
448 if all(condvec < tol) | |
449 condmsg = sprintf(['Fit parameters have reached convergence.\n'... | |
450 'Fit loop was terminated at iteration %s.\n'],num2str(kk)); | |
451 utils.helper.msg(msg.IMPORTANT, condmsg); | |
452 break | |
453 end | |
454 | |
455 | |
456 end %for kk=1:nloops | |
457 | |
458 %%% output data | |
459 % get minimum mse | |
460 if ~isempty(fitmsg) | |
461 val = mse; | |
462 idx = kk; | |
463 else | |
464 mseprog = zeros(numel(loop_results),1); | |
465 for ii=1:numel(loop_results) | |
466 mseprog(ii) = loop_results(ii).mse; | |
467 end | |
468 [val,idx] = min(abs(mseprog-1)); % get the nearest to 1 value | |
469 utils.helper.msg(msg.PROC1, 'Output values at minimum mse, mse = %d\n',val); | |
470 end | |
471 | |
472 % output pest object | |
473 pe = pest(); | |
474 pe.setY(cell2mat(loop_results(idx).params)); | |
475 pe.setDy(sqrt(diag(loop_results(idx).Ca))); | |
476 pe.setCov(loop_results(idx).Ca); | |
477 pe.setChi2(loop_results(idx).mse); | |
478 pe.setNames(fitparams); | |
479 pe.setDof(dof); | |
480 pe.setModels(outmod); | |
481 pe.setName(sprintf('linfitsvd(%s)', mod.name)); | |
482 pe.setProcinfo(plist('loop_results',loop_results)); | |
483 | |
484 % set History | |
485 pe.addHistory(getInfo('None'), pl, [mtxs_invars(:)], [inhists(:)]); | |
486 varargout{1} = pe; | |
487 | |
488 | |
489 | |
490 end | |
491 | |
492 %-------------------------------------------------------------------------- | |
493 % check fit accuracy and stability | |
494 %-------------------------------------------------------------------------- | |
495 function msg = checkfit(V,aa) | |
496 | |
497 if size(V,1)<numel(aa) | |
498 % The number of parameters combinations is less than the number of fit | |
499 % parameters. Information cannot be recostructed fit results will be | |
500 % compromised | |
501 VV = abs(V).^2; | |
502 num = numel(aa)-size(V,1); | |
503 mVV = max(VV); | |
504 % try to identify non measured params | |
505 unmparams = []; | |
506 for jj = 1:num | |
507 [vl,idx] = min(mVV); | |
508 unmparams = [unmparams idx]; | |
509 mVV(idx) = []; | |
510 end | |
511 msg = sprintf(['!!! The number of parameters combinations is less than the number of fit parameters. \n' ... | |
512 'Information cannot be recostructed and fit results will be compromised. \n'... | |
513 'Try to remove parameters %s from the fit parameters list or add information with more experiments !!!\n'],num2str(unmparams)); | |
514 | |
515 else | |
516 | |
517 unmparams = []; | |
518 trh1 = 1e-4; | |
519 | |
520 % eigenvectors are normalized, therefore square of the rows of V are sum | |
521 % to one. Each column of V store the coefficients for a given parameter | |
522 % for the set of eigenvectors | |
523 for jj = 1:size(V,2) | |
524 cl = abs(V(:,jj)).^2; | |
525 if all(cl<trh1) | |
526 unmparams = [unmparams jj]; | |
527 end | |
528 end | |
529 if ~isempty(unmparams) | |
530 msg = sprintf(['!!! Parameter/s %s is/are not well measured. \n'... | |
531 'Fit accuracy could be impaired. \n'... | |
532 'Try to remove such parameters from the fit parameters list !!!\n'],num2str(unmparams)); | |
533 else | |
534 msg = ''; | |
535 end | |
536 end | |
537 | |
538 | |
539 | |
540 | |
541 | |
542 end | |
543 | |
544 %-------------------------------------------------------------------------- | |
545 % calculate frequency response of diagonal elements of the whitening filter | |
546 %-------------------------------------------------------------------------- | |
547 function rsp = getWFresp(wf,f,fs) | |
548 % run over wf elements | |
549 obj = wf.objs; | |
550 [rw,cl] = size(obj); | |
551 if rw~=cl | |
552 error('??? Matrix of whitening filter must be square'); | |
553 end | |
554 amdl = ao.initObjectWithSize(rw,1); | |
555 for jj=1:rw | |
556 % check filter type | |
557 switch lower(class(obj(jj,jj))) | |
558 case 'filterbank' | |
559 % get filter response on given frequencies | |
560 amdly = utils.math.mtxiirresp(obj(jj,jj).filters,f,fs,obj(jj,jj).type); | |
561 amdl(jj,1) = ao(fsdata(f, amdly, fs)); | |
562 case 'miir' | |
563 % get filter response on given frequencies | |
564 amdly = utils.math.mtxiirresp(obj(jj,jj),f,fs,[]); | |
565 amdl(jj,1) = ao(fsdata(f, amdly, fs)); | |
566 end | |
567 end | |
568 rsp = matrix(amdl,plist('shape',[rw 1])); | |
569 | |
570 end | |
571 | |
572 %-------------------------------------------------------------------------- | |
573 % Join Symbolic model and whitening filter for fast calculations | |
574 %-------------------------------------------------------------------------- | |
575 function jmod = joinmodelandfilter(smod,fil) | |
576 switch class(smod) | |
577 case 'matrix' | |
578 mobj = smod.objs; | |
579 [nn,mm] = size(mobj); | |
580 nmobj = collection.initObjectWithSize(nn,mm); | |
581 for ii=1:nn | |
582 for jj=1:mm | |
583 nmobj(ii,jj) = collection(fil.objs(ii,1),mobj(ii,jj)); | |
584 nmobj(ii,jj).setName(mobj(ii,jj).name); | |
585 end | |
586 end | |
587 jmod = matrix(nmobj, plist('shape',[nn,mm])); | |
588 jmod.setName(smod.name); | |
589 case 'collection' | |
590 matobj = matrix.initObjectWithSize(1,numel(smod.objs)); | |
591 for kk=1:numel(smod.objs) | |
592 mobj = smod.objs{kk}.objs; | |
593 [nn,mm] = size(mobj); | |
594 nmobj = collection.initObjectWithSize(nn,mm); | |
595 for ii=1:nn | |
596 for jj=1:mm | |
597 nmobj(ii,jj) = collection(fil.objs(ii,1),mobj(ii,jj)); | |
598 nmobj(ii,jj).setName(mobj(ii,jj).name); | |
599 end | |
600 end | |
601 matobj(kk) = matrix(nmobj); | |
602 matobj(kk).setName(smod.objs{kk}.name); | |
603 %smod.objs{kk} = matobj; | |
604 end | |
605 jmod = collection(matobj); | |
606 end | |
607 | |
608 end | |
609 | |
610 %-------------------------------------------------------------------------- | |
611 % Get Info Object | |
612 %-------------------------------------------------------------------------- | |
613 function ii = getInfo(varargin) | |
614 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
615 sets = {}; | |
616 pl = []; | |
617 else | |
618 sets = {'Default'}; | |
619 pl = getDefaultPlist; | |
620 end | |
621 % Build info object | |
622 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.sigproc, '$Id: linfitsvd.m,v 1.38 2011/04/08 08:56:32 hewitson Exp $', sets, pl); | |
623 ii.setArgsmin(1); | |
624 ii.setOutmin(1); | |
625 ii.setOutmax(1); | |
626 ii.setModifier(false); | |
627 end | |
628 | |
629 %-------------------------------------------------------------------------- | |
630 % Get Default Plist | |
631 %-------------------------------------------------------------------------- | |
632 function plout = getDefaultPlist() | |
633 persistent pl; | |
634 if exist('pl', 'var')==0 || isempty(pl) | |
635 pl = buildplist(); | |
636 end | |
637 plout = pl; | |
638 end | |
639 | |
640 function pl = buildplist() | |
641 | |
642 % General plist for moltichannel fits | |
643 pl = plist.MCH_FIT_PLIST; | |
644 | |
645 | |
646 % p = param({'FitParams','A cell array with the names of the fit parameters'}, {}); | |
647 % pl.append(p); | |
648 | |
649 p = param({'BoundedParams','A cell array with the names of the bounded fit parameters'}, {}); | |
650 pl.append(p); | |
651 | |
652 p = param({'BoundVals','A cell array with the boundaries values for the bounded fit parameters'}, {}); | |
653 pl.append(p); | |
654 | |
655 % p = param({'Model','System parametric model. A matrix of smodel objects or a ssm object'}, paramValue.EMPTY_DOUBLE); | |
656 % pl.append(p); | |
657 | |
658 p = param({'dModel','Partial derivatives of the system parametric model. A matrix of smodel objects'}, paramValue.EMPTY_DOUBLE); | |
659 pl.append(p); | |
660 | |
661 % p = param({'InNames','A cell array containing cell arrays of the input ports names for each experiment. Used only with ssm models.'}, {}); | |
662 % pl.append(p); | |
663 % | |
664 % p = param({'OutNames','A cell array containing cell arrays of the output ports names for each experiment. Used only with ssm models.'}, {}); | |
665 % pl.append(p); | |
666 | |
667 % p = param({'Input','Collection of input signals'},paramValue.EMPTY_DOUBLE); | |
668 % pl.append(p); | |
669 | |
670 p = param({'WhiteningFilter','The multichannel whitening filter. A matrix object of filters'},paramValue.EMPTY_DOUBLE); | |
671 pl.append(p); | |
672 | |
673 p = param({'Nloops', 'Number of desired iteration loops.'}, paramValue.DOUBLE_VALUE(1)); | |
674 pl.append(p); | |
675 | |
676 p = param({'Ncut', 'Number of bins to be discharged in order to cut whitening filter transients'}, paramValue.DOUBLE_VALUE(100)); | |
677 pl.append(p); | |
678 | |
679 % Number of points for zero padding | |
680 p = param({'Npad', 'Number of points for zero padding.'}, paramValue.EMPTY_DOUBLE); | |
681 pl.append(p); | |
682 | |
683 p = param({'KnownParams', 'Known Parameters. A pest object containing parameters values, names and errors'}, paramValue.EMPTY_DOUBLE); | |
684 pl.append(p); | |
685 | |
686 p = param({'tol','Convergence threshold for fit parameters'}, paramValue.DOUBLE_VALUE(1)); | |
687 pl.append(p); | |
688 | |
689 p = param({'fast',['Using fast option causes the whitening filter to be applied in frequency domain.'... | |
690 'The filter matrix is considered diagonal. The method skip time domain filtering saving some process time'... | |
691 'It works only when the imput model is a matrix of smodels']}, paramValue.FALSE_TRUE); | |
692 pl.append(p); | |
693 | |
694 p = param({'SetAlias','Set to true in order to aassign internally the values to the model alias'}, paramValue.FALSE_TRUE); | |
695 pl.append(p); | |
696 | |
697 p = param({'sThreshold',['Fix upper treshold for singular values.'... | |
698 'Singular values larger than the value will be ignored.'... | |
699 'This correspon to consider only parameters combinations with error lower then the value']},... | |
700 paramValue.DOUBLE_VALUE(1)); | |
701 pl.append(p); | |
702 | |
703 p = plist({'diffStep','Numerical differentiation step for ssm models'}, paramValue.EMPTY_DOUBLE); | |
704 pl.append(p); | |
705 | |
706 | |
707 | |
708 end |