Add examples for armax, armax1 & initstate 24/10224/3
Sylvestre Ledru [Wed, 16 Jan 2013 08:27:00 +0000 (09:27 +0100)]
Note that the inistate example will fail because of:
http://bugzilla.scilab.org/show_bug.cgi?id=11938

Change-Id: Ia531fe39b7cac0c4dfda1e3f2170b2ddc1ffffec

scilab/modules/cacsd/help/en_US/armax.xml
scilab/modules/cacsd/help/en_US/armax1.xml
scilab/modules/cacsd/help/en_US/inistate.xml
scilab/modules/helptools/images/armax_1.png [new file with mode: 0644]

index a1cb3b9..8feb170 100644 (file)
@@ -120,7 +120,8 @@ Acoeff=Armaest('a');    //Coefficients of the polynomial A(x)
 Bcoeff=Armaest('b')     //Coefficients of the polynomial B(x)
 Dcoeff=Armaest('d');    //Coefficients of the polynomial D(x)
 [Ax,Bx,Dx]=arma2p(Armaest)   //Results in polynomial form. 
-
+ ]]></programlisting>
+        <programlisting role="example"><![CDATA[ 
 //-Ex2- Arma1: y_t -0.8*y_{t-1} + 0.2*y_{t-2} =  sig*e(t)
 ny=1,nu=1;sig=0.001;
 // First step: simulation the Arma1 model, for that we define
@@ -136,6 +137,34 @@ y=arsimul(Arma2,u); // y = output of Arma2 with input u
 Arma1est=armax(2,-1,y,[]);
 [A,B,D]=arma2p(Arma1est)
  ]]></programlisting>
+        <programlisting role="example"><![CDATA[ 
+a = [1, -2.851, 2.717, -0.865];
+b = [0, 1, 1, 1];
+d = [1, 0.7, 0.2];
+ar = armac(a, b, d, 1, 1, 1);
+disp(_("Simulation of an ARMAX process:"));
+disp(ar);
+// The input
+n = 300;
+u = -prbs_a(n, 1, int([2.5,5,10,17.5,20,22,27,35]*100/12));
+// simulation
+zd = narsimul(ar, u);
+
+// visualization
+plot2d(1:n,[zd',1000*u'],style=[1,3]);curves = gce();
+legend(["Simulated output";"Input [scaled]"])
+ ]]></programlisting>
+        <scilab:image>
+            a = [1, -2.851, 2.717, -0.865];
+            b = [0, 1, 1, 1];
+            d = [1, 0.7, 0.2];
+            ar = armac(a, b, d, 1, 1, 1);
+            n = 300;
+            u = -prbs_a(n, 1, int([2.5,5,10,17.5,20,22,27,35]*100/12));
+            zd = narsimul(ar, u);
+            plot2d(1:n,[zd',1000*u'],style=[1,3]);curves = gce();
+            legend(["Simulated output";"Input [scaled]"]);
+        </scilab:image>
     </refsection>
     <refsection role="see also">
         <title>See Also</title>
index bfb1f0e..6221ab5 100644 (file)
@@ -95,7 +95,7 @@
             armax1 is used to identify the coefficients of a 1-dimensional 
             ARX process:
         </para>
-        <programlisting role=""><![CDATA[ 
+        <programlisting role="no-scilab-exec"><![CDATA[ 
 A(z^-1)y= B(z^-1)u + D(z^-1)sig*e(t)
 e(t) is a 1-dimensional white noise with variance 1.
 A(z)= 1+a1*z+...+a_r*z^r; ( r=0 => A(z)=1)
@@ -106,14 +106,14 @@ D(z)= 1+d1*z+...+d_q*z^q  ( q=0 => D(z)=1)
             for the method, see Eykhoff in trends and progress in system
             identification) page 96.  with
         </para>
-        <programlisting role=""><![CDATA[ 
+        <programlisting role="no-scilab-exec"><![CDATA[ 
 z(t)=[y(t-1),..,y(t-r),u(t),...,
       u(t-s),e(t-1),...,e(t-q)] 
  ]]></programlisting>
         <para>
             and
         </para>
-        <programlisting role=""><![CDATA[ 
+        <programlisting role="no-scilab-exec"><![CDATA[ 
 coef= [-a1,..,-ar,b0,...,b_s,d1,...,d_q]'
 y(t)= coef'* z(t) + sig*e(t).
  ]]></programlisting>
@@ -123,6 +123,31 @@ y(t)= coef'* z(t) + sig*e(t).
             a sequential version of armax
         </para>
     </refsection>
+    
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[ 
+
+a = [1, -2.851, 2.717, -0.865];
+b = [0, 1, 1, 1];
+d = [1, 0.7, 0.2];
+ar = armac(a, b, d, 1, 1, 1);
+disp(_("Simulation of an ARMAX process:"));
+disp(ar);
+
+n = 300;
+u = -prbs_a(n, 1, int([2.5,5,10,17.5,20,22,27,35]*100/12));
+zd = narsimul(ar, u);
+
+// using now armax1 : coloured noise identification
+// you can test the same example with
+[arc1, resid] = armax1(3,3,2,zd(1:n),u,1);
+disp(arc1);
+
+ ]]></programlisting>
+    </refsection>
+    
+    
     <refsection>
         <title>Important notice</title>
         <para>In Scilab versions up to 4.1.2 the returned value in
index f33f86d..d8999e5 100644 (file)
@@ -128,6 +128,32 @@ y(k)   = Cx(k) + Du(k),
             number of the coefficient matrix of the least squares problem solved.
         </para>
     </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[ 
+//generate data from a given linear system
+A = [ 0.5, 0.1,-0.1, 0.2;
+      0.1, 0,  -0.1,-0.1;      
+     -0.4,-0.6,-0.7,-0.1;  
+      0.8, 0,  -0.6,-0.6];      
+B = [0.8;0.1;1;-1];
+C = [1 2 -1 0];
+SYS=syslin(0.1,A,B,C);
+nsmp=100;
+U=prbs_a(nsmp,nsmp/5);
+Y=(flts(U,SYS)+0.3*rand(1,nsmp,'normal'));
+
+// Compute R
+S=15;
+[R,N1,SVAL] = findR(S,Y',U');
+N=3;
+SYS1 = findABCD(S,N,1,R) ;
+SYS1.dt=0.1;
+
+inistate(SYS1,Y',U')
+
+]]></programlisting>
+    </refsection>
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">
diff --git a/scilab/modules/helptools/images/armax_1.png b/scilab/modules/helptools/images/armax_1.png
new file mode 100644 (file)
index 0000000..122ff26
Binary files /dev/null and b/scilab/modules/helptools/images/armax_1.png differ