# you must have scilab in your path, like below
import os
os.environ["PATH"] = os.environ["PATH"]+";"+r"C:\Users\famille\AppData\Local\scilab-5.4.1\bin"
# this currently suppose to have done pip install import scilab2py
# with scilab2py > 0.3 (not yet out)
import scilab2py
import numpy as np
sci = scilab2py.Scilab2Py()
x = sci.eval("zeros(3,3)")
x
array([[ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.]])
%load_ext scilab2py.ipython
x = %scilab 2+2
4.0
x = %scilab [1 2; 3 4];
x
[[ 1. 2.] [ 3. 4.]]
array([[ 1., 2.], [ 3., 4.]])
a = [1, 2, 3]
%scilab_push a
%scilab a = a * 2;
%scilab_pull a
a
array([[ 2., 4., 6.]])
%%scilab -i x -o y
y = x + 3;
y
[[ 4. 5.] [ 6. 7.]]
%%scilab -f svg
xset("fpf"," ")
contour2d(1:10,1:10,rand(10,10),5,rect=[0,0,11,11]);
[[ 0.82763768 0.66215437 0.49667106 0.33118775 0.16570444]]
%%scilab -f jpg
# simple plot using z = f(x, y)
t = [0: 0.3: 2 * %pi]';
z = sin(t) * cos(t');
plot3d(t, t, z);
sci=scilab2py.Scilab2Py()
sci.eval("2+2")
4.0
%%scilab -f png
[x, y] = meshgrid(0:0.1:3);
r = sin(x - 0.5).^2 + cos(y - 0.5).^2;
surf(x, y, r);
%%scilab -g
plot([1,2,3])
# brings up a Scilab plotting GUI
%scilab exists ones
0.0
0.0