Bump version numbers to 6.2.0
[scilab.git] / scilab / modules / cacsd / tests / unit_tests / dscr.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2008 - INRIA - Serge Steer
4 // Copyright (C) 2011 - DIGITEO - Michael Baudin
5 //
6 //  This file is distributed under the same license as the Scilab package.
7 // =============================================================================
8
9
10
11 // Case #1
12 a=-1/3;
13 b=1;
14 c=1;
15 sl=syslin("c",a,b,c);
16 sld=dscr(sl,0.1);
17 assert_checkequal ( sld.dt , 0.1);
18 assert_checkalmostequal (sld.A ,exp(sl.A*0.1));
19 assert_checkalmostequal (sld.B , sl.A\(sld.A-eye())*sl.B );
20
21 assert_checktrue(sld==dscr(zpk(sl),0.1));
22 assert_checktrue(sld==dscr(ss2tf(sl),0.1));
23
24 // Case #2
25 a=[0.9,0,0.6,-1.4,-4.2;
26    0.2,0.1,-0.2,0.5,0.6;
27    -4.3,0,2.2,0,2.4;
28    -3.7,-0.5,2.4,-0.6,2.7;
29    6.4,0.1,-4,-0.5,-4];
30
31 b=[-0.1,-0.1,0;
32    0,0,0.1;
33    -0.1,0.2,-0.1;
34    0.2,0.2,-0.6;
35    0.2,-0.1,0.1];
36  
37 c=[2,7,-2,5,1
38    0,-1,3,0,2];
39 d=[1,0,0
40    0,0,0];
41
42 sl=syslin('c',a,b,c,d);
43 sld=dscr(sl,0.1);
44 assert_checkequal ( sld.dt , 0.1);
45 assert_checkalmostequal (sld.A ,expm(sl.A*0.1));
46 assert_checkalmostequal (sld.B , sl.A\(sld.A-eye())*sl.B);
47
48 S=zpk({[],1},{-1,[-2 -3]},[1 1],"c");
49 assert_checktrue(dscr(zpk2ss(S),0.1)==dscr(S,0.1));
50