<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="ssrand" xml:lang="en">
    <refnamediv>
        <refname>ssrand</refname>
        <refpurpose>random system generator</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>sl=ssrand(nout,nin,nstate)
            [sl,U]=ssrand(nout,nin,nstate,flag)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>nout</term>
                <listitem>
                    <para>integer (number of output)</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>nin</term>
                <listitem>
                    <para>integer (number of input)</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>nstate</term>
                <listitem>
                    <para>integer (dimension of state-space)</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>flag</term>
                <listitem>
                    <para>list made of one character string and one or several
                        integers
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>sl</term>
                <listitem>
                    <para>
                        list (<literal>syslin</literal> list)
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>U</term>
                <listitem>
                    <para>
                        square <literal>(nstate x nstate)</literal> nonsingular
                        matrix
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <literal>sl=ssrand(nout,nin,nstate)</literal> returns a random
            strictly proper (<literal>D=0</literal>) state-space system of size
            <literal>[nout,nint]</literal> represented by a <literal>syslin</literal>
            list and with <literal>nstate</literal> state variables.
        </para>
        <para>
            <literal>[sl,U]=ssrand(nout,nin,nstate,flag)</literal> returns a
            test linear system with given properties specified by
            <literal>flag</literal>. <literal>flag</literal> can be one of the
            following:
        </para>
        <programlisting><![CDATA[
flag=list('co',dim_cont_subs)
flag=list('uo',dim_unobs_subs)
flag=list('ncno',dim_cno,dim_ncno,dim_co,dim_nco)
flag=list('st',dim_cont_subs,dim_stab_subs,dim_stab0)
flag=list('dt',dim_inst_unob,dim_instb0,dim_unobs)
flag=list('on',nr,ng,ng0,nv,rk)
flag=list('ui',nw,nwu,nwui,nwuis,rk)
 ]]></programlisting>
        <para>
            The complete description of the <literal>Sys</literal> is given in
            the code of the <literal>ssrand</literal> function (in
            <literal>SCI/modules/cacsd/macros/</literal>). For example with
            <literal>flag=list('co',dim_cont_subs)</literal> a non-controllable system
            is return and <literal>dim_cont_subs</literal> is the dimension of the
            controllable subspace of <literal>Sys</literal>. The character strings
            <literal>'co','uo','ncno','st','dt','on','ui'</literal> stand for
            "controllable", "unobservable", "non-controllable-non-observable",
            "stabilizable","detectable","output-nulling","unknown-input".
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
//flag=list('st',dim_cont_subs,dim_stab_subs,dim_stab0)
//dim_cont_subs<=dim_stab_subs<=dim_stab0
//pair (A,B) U-similar to:
//    [*,*,*,*;     [*;
//    [0,s,*,*;     [0;
//A=  [0,0,i,*;   B=[0;
//    [0,0,0,u]     [0]
//
// (A11,B1) controllable  s=stable matrix i=neutral matrix u=unstable matrix
[Sl,U]=ssrand(2,3,8,list('st',2,5,5));
w=ss2ss(Sl,inv(U)); //undo the random change of basis => form as above
[n,nc,u,sl]=st_ility(Sl);n,nc
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="syslin">syslin</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
