GNU Octave Part 1 - Big picture

What’s Octave? According to the website —

  • Powerful mathematics-oriented syntax with built-in 2D/3D plotting and visualization tools
  • Free software, runs on GNU/Linux, macOS, BSD, and Microsoft Windows
  • Drop-in compatible with many Matlab scripts (largely compatible with Matlab)

Download from official website and let’s get started. In this short article we gonna explore what Octave can do.

2D plott

x = -2:0.5:2;
y = x .^ 2;
plot(x,y);
title("Simple 2-D Plot");
xlabel("X");
ylabel("Y");
2D plotting with Octave
2D plotting with Octave

Beginner note: as soon as you use plot() method, a diagram will appear on GUI, then keep labeling the diagram and it will sync automatically.

3D plot

x = linspace(-2,2,50);
y = linspace(-2,2,50);
[xx,yy] = meshgrid(x,y);
meshc(xx, yy, 4-(xx .^ 2 + yy .^ 2));
3D plotting with Octave
3D plotting with Octave

Elementary Calculations

For example, exponent to the multiplication of i and pi

exp (i*pi)

Matrix Arithmetic

Let a be a simple 2x2 matrix and multiply with A transpose, just like math we can simple write.

A = [1 2; 3 4];
A * A';

Huge libs

Octave has build-in function libraries to enhance programmability, sin() cost() etc. Helper function for quick util like —

toupper();  
lookfor -all "standard deviation";

Package

The package is the bundle of functions providing extra functionality for GNU Octave. Octave Forge is a central location for the development of packages for GNU Octave.

pkg install -forge package_name;

Tricks

  • Semicolon at the end of each statement, will prevent from console out e.g
a = 5;
  • It’s dynamic type language, variable copy by value and case sensitive
a = "text";
b = a;
a = 1;
% a is 1 now, while b remain as 'text'
  • It has both C-like Structures and Python style (mixed)

Math problems

Solving Systems of Linear Equations, Integrating Differential Equations and more.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aung Zan Baw

Aung Zan Baw

Full stack developer, base in Myanmar. Turn coffee into code, a husband, a father, a reader.