
Contents
- 実行環境
- 準備 …
Scilab インストール - 確認 …
Cygwin シェルからの起動、データの渡し方 - psql
からデータを渡してプロット ※上の画像に関する箇所 : こちら
実行環境
••
•
•
psql
Scilab
冒頭に書いたとおり
今回の実行環境とは別に、職場の
準備 … Scilab インストール
インストーラ


次のコンポーネント選択が重要。デフォルトがフルインストールで、このまま進めないと起動しませんでした。当初

↓ スタートメニュー、拡張子の関連付け等の設定を経てインストール開始。この後ポータブル化するので関連付けは全部外しました(アンインストーラが消すと思うけど)。



↓ プログラムフォルダ下はこんな感じ。丸ごと適当な場所にコピーし、アンインストーラで
ScilabDir |-- .atoms |-- bin |-- Scilex.exe |-- WScilex.exe |-- contrib |-- etc |-- java |-- libs |-- locale |-- modules |-- thirdparty |-- tools
WScilex.exe


残念なのはコンソールのキャレット(テキストカーソル)が常時点滅しており、止める設定が見つからないこと。せっかくですが
CUI
↓ コマンドプロンプトから

↓ 起動オプションはいろいろあるけど、CUI
> Scilex -h scilex: run Scilab. Arguments: passes Arguments to Scilab, This Arguments can be retreived by the Scilab function sciargs. -e Instruction: execute the scilab instruction given in Instruction argument. -f File: execute the scilab script given in File argument. '-e' and '-f' options are mutually exclusive. -l lang: it fixes the user language. -mem N: set the initial stacksize. -ns: if this option is present the startup file scilab.start is not executed. -nb: if this option is present then Scilab loading message is not displayed. -nouserstartup: don't execute user startup files SCIHOME/.scilab or SCIHOME/scilab.ini. -nw: start Scilab without specialized Scilab Window. -nwni: start Scilab without user interaction (batch mode). -nogui: start Scilab without GUI,tcl/tk and user interaction (batch mode). -texmacs: reserved for WinTeXMacs. -version: print product version and exit.
今回、Scilab

Scilab
--> titlepage('_{n}\mathrm{C}_{r} = \frac{n!}{(n-r)!r!}')

確認 … Cygwin シェルからの起動、データの渡し方
前項での$ d:/works/scilab/current/bin/scilex Error: Impossible to define SCIHOME environment variable.

SCIHOME
$ export SCIHOME=d:/works/scilab/current $ $SCIHOME/bin/scilex Scilab 5.5.2 (Mar 31 2015, 12:04:21) -->

他のソフトウェアと同様、起動時オプションの
Arguments + pipe
...
"Even when Scilab is used through a pipe, it is possible to use the arguments. Arguments are processed first."
載っているサンプルを実行すると ↓ 確かにそうでした。まず
echo 'disp(%pi*2)' | $SCIHOME/bin/scilex -e 'disp(%pi)' Scilab 5.5.2 (Mar 31 2015, 12:04:21) 3.1415927 6.2831853 $

というわけで
↓ テスト。環境変数にパス(+
$ export scilab="$SCIHOME/bin/scilex -nb" $ echo '1 2 3 9 9 6' > tmp6 $ $scilab -e 'd=fscanfMat("tmp6"); plot(d(:,1), d(:,2))' -->

グラフが別ウィンドウに出たけど、コンソールにフォーカスを戻し対話シェルで待機する動作でした。だから場合によってはグラフが隠れます。gnuplot
ところでデータ読み込みの際、Octave
↓ もう一つテスト。今度は対話シェルに戻らずグラフを出して止め、閉じるかグラフ内クリックで
$ export scilab="$SCIHOME/bin/scilex -nb" $ echo '1 2 3 9 9 6' > tmp6 $ $scilab -e 'd=fscanfMat("tmp6"); plot(d(:,1), d(:,2)); xclick; exit'

意図せずグラフ内をクリックして閉じられると困るので、何か
ここまでが準備と確認。長かったですが、結局
psql からデータを渡してプロット
↓ グラフを出して止める例です。最初に環境変数をセット、続いてクエリ結果の出力を「データだけ、半角空白区切り」に。そしてクエリ、結果を-- set environmental variables # \setenv SCIHOME 'd:/works/scilab/current' # \setenv scilab `echo $SCIHOME`'/bin/Scilex -nb' -- set output format # \f ' ' \\\t on \\\pset format unaligned -- query and send command to scilab # select x, y, sin(r) / r from generate_series(-8, 8, 0.4) as x, generate_series(-8, 8, 0.4) as y, cast(sqrt(x^2 + y^2) + 1e-9 as float) as r \g tmp6 # \! $scilab -e 'd=fscanfMat("tmp6"); nc=length(unique(d(:,1))); surf(matrix(d(:,3), nc, nc)); f=get("current_figure"); f.color_map=[1,1,1]; xclick; exit'

クエリ内容はOctave
surf(MATRIX, 'facecol', 'white')
同様に「対話シェルでは使えても
-- set environmental variables # \setenv SCIHOME 'd:/works/scilab/current' # \setenv scilab `echo $SCIHOME`'/bin/Scilex -nb' -- set output format # \f ' ' \\\t on \\\pset format unaligned -- query and send command to scilab # \g tmp6 \\\! $scilab -e 'd=fscanfMat("tmp6")' --> nc=length(unique(d(:,1))); --> surf(matrix(d(:,3), nc, nc), 'facecol', 'interp') --> title '$\large z=\frac{\sin(\sqrt{x^2+y^2})}{\sqrt{x^2+y^2}}$'

この配色がデフォルトという…まぁ色の好みはそれぞれです。グラフウィンドウから保存した
今日を含め