<TeXmacs|1.99.2>

<style|<tuple|tmdoc|maxima|scilab|english>>

<\body>
  <\tmdoc-title>
    Example <name|Scilab> session
  </tmdoc-title>

  <subsection|Mathematical presentation of <name|Scilab> data types>

  Here follow some sample sessions started using
  <menu|Insert|Session|Scilab>.

  <\session|scilab|default>
    <\output>
      \ \ \ \ \ \ \ \ ___________________________________________
      \ \ \ \ \ \ \ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ scilab-5.3.3

      \;

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Consortium Scilab (DIGITEO)

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ Copyright (c) 1989-2011 (INRIA)

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ Copyright (c) 1989-2007 (ENPC)

      \ \ \ \ \ \ \ \ ___________________________________________
      \ \ \ \ \ \ \ 

      \;
    </output>

    <\unfolded-io>
      --\<gtr\>
    <|unfolded-io>
      <\code>
        A= [0,1;0,0], B= [1;1]; C= [1,1];
      </code>
    <|unfolded-io>
      \ A \ =

      \ 

      <with|mode|math|<matrix|<tformat|<table|<row|<cell|0>|<cell|1>>|<row|<cell|0>|<cell|0>>>>>>

      \ 
    </unfolded-io>

    <\unfolded-io>
      --\<gtr\>
    <|unfolded-io>
      <\code>
        S1= syslin('c',A,B,C)
      </code>
    <|unfolded-io>
      \ S1 \ =

      \ 

      <with|mode|math|<choice|<tformat|<cwith|1|-1|1|1|cell-halign|r>|<table|<row|<cell|<wide|X|\<dot\>>
      <around*|(|t|)>>|<cell|=>|<cell|<matrix|<tformat|<table|<row|<cell|0>|<cell|1>>|<row|<cell|0>|<cell|0>>>>>*X
      <around*|(|t|)>+<matrix|<tformat|<table|<row|<cell|1>>|<row|<cell|1>>>>>*U
      <around*|(|t|)>>>|<row|<cell|Y <around*|(|t|)>>|<cell|=>|<cell|<matrix|<tformat|<table|<row|<cell|1>|<cell|1>>>>>*X
      <around*|(|t|)>>>>>>>

      \ 
    </unfolded-io>

    <\unfolded-io>
      --\<gtr\>
    <|unfolded-io>
      demo_run (texmacs_path + '/plugins/scilab/bin/scilab-demo.sce')
    <|unfolded-io>
      \;
    </unfolded-io>
  </session>

  <strong|<with|color|red|Note.>> Most of the <name|Scilab> data types are
  handled. However, there are issues printing some of them because of the
  simplicity in the <name|Scilab> read-eval-print loop (see e.g. the case of
  <scilab|mlist>: it is currently impossible to know the name of the
  variable). Also, some types cannot be printed since the printing method
  cannot be overloaded in <name|Scilab> for this type (see e.g. the case of
  <scilab|sparse matrix>; Sparse matrices can nevertheless be printed, using
  <scilab|tmout>).

  <strong|<with|color|red|Note.>> Again due to the <name|Scilab>
  read-eval-print loop, multiline commands may fail (at least,
  <scilab|function> declarations and entries with comments or continuation
  marks (<scilab|..>)).

  <strong|<with|color|red|Note.>> There are some performance issues when
  working with large data sets. The <scilab|tmstree()> function could be
  improved i) by removing local function definitions; ii) by limiting
  repeated calls to small functions (avoiding code factorization); and iii)
  via a different handling of matrices.

  <subsection|Syntax highlighting>

  Here follows a sample block of code, which was started using
  <menu|Insert|Program|Block of code|Scilab>. Inserting <em|inline code> is
  also possible, e.g. to write ``<scilab|f(x,y+1)>''.

  <\scilab-code>
    g= 9.81 // the gravity

    \;

    function y= myfunction(x)

    \ \ // myfunction computes y= x^2+1

    \ \ // x should be a vector or matrix

    \ \ y= x^2+1

    endfunction
  </scilab-code>

  <subsection|Plot insertion>

  The function <scilab|plotout()> allows you to insert the current figure
  inside the <TeXmacs> session. It is inserted as an image whose size you can
  edit as any other image.

  <\session|scilab|default>
    <\unfolded-io>
      --\<gtr\>
    <|unfolded-io>
      x= -6.28:0.1:6.28; y= sin(x); plot (x, y);

      // Note: leave the plot window open
    <|unfolded-io>
      \ 
    </unfolded-io>

    <\unfolded-io>
      --\<gtr\>
    <|unfolded-io>
      plotout()
    <|unfolded-io>
      <image|<tuple|<#[encoded data, 29568 characters]>|ps>|0.7par|||>
    </unfolded-io>

    <\input>
      --\<gtr\>
    <|input>
      \;
    </input>
  </session>

  <subsection|Menu populating features>

  The <name|Scilab> menu has an entry <menu|Insert> which can be
  personalized. As an example, the session

  <\session|scilab|default>
    <\unfolded-io>
      --\<gtr\>
    <|unfolded-io>
      cf= ["abort", "break", "case", "continue", "do", "for", "if", "pause",
      "resume", "return", "select", "then", "while"];
    <|unfolded-io>
      \ 
    </unfolded-io>

    <\folded-io>
      --\<gtr\>
    <|folded-io>
      add_to_insert_menu ("Control flow", cf);
    <|folded-io>
      \ 
    </folded-io>
  </session>

  adds the entry <menu|Scilab|Insert|Control flow> to the <name|Scilab> menu.
  It can be removed using

  <\session|scilab|default>
    <\folded-io>
      --\<gtr\>
    <|folded-io>
      rm_from_insert_menu ("Control flow");
    <|folded-io>
      \ 
    </folded-io>
  </session>

  <subsection|Completion>

  <name|Scilab> object names can be completed by pressing the <key|tab> key.

  <subsection|Verbatim import>

  <TeXmacs> allows you to edit a <name|Scilab> source in verbatim mode. See
  e.g. <hlink|<verbatim|scilab-demo.sce>|../bin/scilab-demo.sce>.

  <subsection|Launching demos>

  The <name|Scilab> menu lists the available <name|Scilab> demos. They can be
  launched, via <menu|Scilab|Launch demo>.

  <subsection|Help browsing>

  To be done.

  <tmdoc-copyright|2013|François Poulain, Joris van der Hoeven. Examples
  inspired from Scilab documentation.>

  <tmdoc-license|Permission is granted to copy, distribute and/or modify this
  document under the terms of the GNU Free Documentation License, Version 1.1
  or any later version published by the Free Software Foundation; with no
  Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  Texts. A copy of the license is included in the section entitled "GNU Free
  Documentation License".>
</body>

<initial|<\collection>
</collection>>