test program for ltisys library which implements continuous-time linear time-invariant systems

Dependencies:   ltisys mbed

Files at this revision

API Documentation at this revision

Comitter:
maruta
Date:
Sat May 09 02:53:37 2015 +0000
Parent:
2:1b680d1c8048
Commit message:
changed example

Changed in this revision

ltisys.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ltisys.lib	Thu May 07 11:54:49 2015 +0000
+++ b/ltisys.lib	Sat May 09 02:53:37 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/maruta/code/ltisys/#d144578aa744
+http://developer.mbed.org/users/maruta/code/ltisys/#d459418c3440
--- a/main.cpp	Thu May 07 11:54:49 2015 +0000
+++ b/main.cpp	Sat May 09 02:53:37 2015 +0000
@@ -4,18 +4,21 @@
 
 int main() {
     /*
-     the following line is generated by MATLAB by
+     the following line is generated by MATLAB by:
         s=tf('s')
-        sys=1/(s^2+s+1)
-        impl_ltisys(sys,'test_sys')
+        test_sys=[1,1/(s^2+s+1);0.05/s,1/(s+1)]
+        impl_ltisys(test_sys,'test_sys')
+     check the result by comparing with:
+        u=ones(21,1)*[1,2]
+        lsim(test_sys,u,0:20)
     */
-    ltisys<2,1,1> test_sys((double []) {-1.000000e+00,-1.000000e+00,1.000000e+00,0.000000e+00,},(double []) {1.000000e+00,0.000000e+00,},(double []) {0.000000e+00,1.000000e+00,},(double []) {0.000000e+00,});
+    ltisys<4,2,2> test_sys((const double []) {-0.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,-1.000000e+00,-1.000000e+00,0.000000e+00,0.000000e+00,1.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,-1.000000e+00,},(const double []) {2.500000e-01,0.000000e+00,0.000000e+00,1.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,1.000000e+00,},(const double []) {0.000000e+00,0.000000e+00,1.000000e+00,0.000000e+00,2.000000e-01,0.000000e+00,0.000000e+00,1.000000e+00,},(const double []) {1.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,});
 
     // calculate step response of test_sys
-    double u[] = { 1.0 };
+    double u[] = { 1.0 , 2.0};
     double dt=1.0;
     for (double t = 0; t <= 20.0; t+=dt) {
         test_sys.update(dt, u);
-        printf("%f\t%f\t%f\r\n", t, u[0], test_sys.y[0]);
+        printf("%f\t%f\t%f\r\n", t, test_sys.y[0],test_sys.y[1]);
     }
 }