Training Data Visualization Scilab & GNU Octave — Open-Source Alternatives
6 / 10

Scilab & GNU Octave — Open-Source Alternatives

24 min Data Visualization

Scilab & GNU Octave — Open-Source Alternatives

What Are Scilab and GNU Octave?

Scilab is a free, open-source numerical computing platform originally developed by INRIA (France). It offers a MATLAB-like syntax with its own extensions for control systems, signal processing, and optimization.

GNU Octave is a free, open-source language designed to be largely compatible with MATLAB syntax. Most MATLAB scripts run unchanged in Octave.

Key Differences from MATLAB
FeatureMATLABScilabOctave
LicenseCommercialFree (GPL-compatible)Free (GPL)
SyntaxMATLAB syntaxSimilar but has differencesNearly identical to MATLAB
Indexing1-based1-based1-based
Booleantrue/false%T/%Ftrue/false
End keywordendendend or endfor
Plotting engineBuilt-inBuilt-in (different API)gnuplot or Qt
Scilab — Key Syntax
  • Vectors: v = [1 2 3 4 5]; — same as MATLAB
  • Matrices: A = [1 2; 3 4];
  • Colon operator: t = 0:0.1:10;
  • Solving $Ax = b$: x = A \ b; or x = inv(A) * b;
  • Plotting: plot(x, y); xtitle('Title','x','y');
  • Special constants: %pi, %e, %i (imaginary unit), %T/%F (booleans)
GNU Octave — Key Distinctions
  • Compatibility: Most MATLAB .m files run directly.
  • String quoting: Supports both 'text' and "text" (MATLAB only uses single quotes for character arrays).
  • Auto-broadcasting: Octave automatically broadcasts array dimensions; MATLAB requires bsxfun or explicit expansion.
  • Packages: pkg install -forge package_name to add toolbox equivalents from Octave Forge.
When to Use Each Tool
  • MATLAB — industry standard; required in many courses; largest toolbox ecosystem (Simulink, Signal Processing, etc.).
  • GNU Octave — best free substitute for MATLAB homework/scripts; high syntax compatibility.
  • Scilab — Xcos block diagrams (like Simulink); good for control engineering; active European community.
Example 1 — Scilab: Plot a Damped Oscillation

Plot $y = e^{-0.3t}\sin(2\pi t)$ for $0 \le t \le 10$ in Scilab.

t = linspace(0, 10, 500);

y = exp(-0.3*t) .* sin(2*%pi*t);

plot(t, y); xtitle('Damped Oscillation','t (s)','y');

Variables: t — time vector (500 points); y — amplitude at each time; %pi — Scilab's $\pi$ constant.

Example 2 — Octave: Eigenvalue Decomposition

Find eigenvalues of $A = \begin{bmatrix}4&1\\2&3\end{bmatrix}$ in Octave.

A = [4 1; 2 3];

[V, D] = eig(A);

Result: $D = \begin{bmatrix}2&0\\0&5\end{bmatrix}$, so $\lambda_1 = 2,\; \lambda_2 = 5$.

Variables: V — matrix of eigenvectors; D — diagonal matrix of eigenvalues.

Example 3 — Scilab: Contour Plot

Create a contour plot of $f(x,y) = x^2 + y^2$ over $[-3,3] \times [-3,3]$.

x = linspace(-3,3,100); y = x;

[X, Y] = meshgrid(x, y);

Z = X.^2 + Y.^2;

contour(x, y, Z, 10);

Variables: X, Y — 2-D mesh grids; Z — function values; 10 — number of contour levels.

Practice Problems

1. What is the main licensing difference between MATLAB and Scilab?
2. Which free tool has the best MATLAB syntax compatibility?
3. How do you represent $\pi$ in Scilab?
4. What Scilab command adds title and axis labels?
5. How do you install a package in GNU Octave?
6. True or false: Octave supports both single and double-quoted strings.
7. What is Scilab's equivalent of MATLAB's Simulink?
8. Does A \ b work in both Scilab and Octave?
9. What are Scilab's boolean constants?
10. Can you run MATLAB .m files directly in Octave?
11. What is auto-broadcasting in Octave?
12. Name one advantage of Scilab over MATLAB for students.
Show Answer Key

1. MATLAB is commercial/paid; Scilab is free and open-source

2. GNU Octave

3. %pi

4. xtitle('Title','x-label','y-label')

5. pkg install -forge package_name

6. True

7. Xcos

8. Yes

9. %T (true) and %F (false)

10. Most, but not all (toolbox-specific functions may differ)

11. Automatically expands arrays of different dimensions for element-wise operations

12. It is completely free — no license cost