Mercurial > hg > ltpda
diff m-toolbox/test/test_ltpdamodel_inv.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/test/test_ltpdamodel_inv.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,55 @@ +% Test script for ltpdamodel/inv +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% HISTORY: 02-10-2008 L Ferraioli +% Creation +% +% $Id: test_ltpdamodel_inv.m,v 1.2 2009/05/25 15:11:33 luigi Exp $ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Build numeric test matrix + +a=1;b=2;c=3; +d=5;e=2;f=6; +g=1;h=3;i=5; +M=[a,b,c;d,e,f;g,h,i]; +iM = inv(M); + +%% Equivalent ltpdamodel matrix + +A = [ltpdamodel(plist('expression','a','params',{'a'},'values',{1},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... + ltpdamodel(plist('expression','b','params','b','values',2,'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... + ltpdamodel(plist('expression','c','params',{'c'},'values',{3},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m')));... + ltpdamodel(plist('expression','d','params',{'d'},'values',{5},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... + ltpdamodel(plist('expression','e','params','e','values',2,'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... + ltpdamodel(plist('expression','f','params',{'f'},'values',{6},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m')));... + ltpdamodel(plist('expression','g','params',{'g'},'values',{1},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... + ltpdamodel(plist('expression','h','params','h','values',3,'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... + ltpdamodel(plist('expression','i','params',{'i'},'values',{5},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m')))]; + +%% Do inverse and eval + +iA = inv(A); + +%% Numeric eval + +imat = zeros(3,3); +for ii=1:3 + for jj=1:3 + imat(ii,jj)=eval(iA(ii,jj).expr.s); + end +end + +imat-iM + +%% Symbolic test + +B = A*iA; + +%% Numeric eval + +imat2 = zeros(3,3); +for ii=1:3 + for jj=1:3 + imat2(ii,jj)=eval(B(ii,jj).expr.s); + end +end \ No newline at end of file