Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 45 ยท Getting Started

What Are MATLAB and Octave?

Learn what MATLAB and GNU Octave are, how they differ, how compatible they are, what people use them for, and how this tutorial shows the code.

MATLAB is a programming environment built around one idea: almost everything is a matrix. Engineers, scientists and analysts use it to crunch numbers, simulate systems, process signals and images, and draw graphs, usually in a few lines of code. The name is short for "matrix laboratory", and you will see why as soon as you write your first line: a single number is a 1-by-1 matrix, a list is a 1-by-N matrix, and a spreadsheet of values is just a bigger one.

GNU Octave is a free, open-source program that runs most MATLAB code. If you cannot buy MATLAB, or you simply want to learn the language without a license, Octave is a good place to start. This lesson explains how the two relate, what you can build with them, and how this tutorial handles the fact that neither one runs inside your browser.

One language family, two programs

MATLAB Commercial product from MathWorks.
GNU Octave Free and open source.
Mostly compatible Most beginner code runs in both.

Learn the shared core first, the differences later.

1 / 2

What MATLAB is

MATLAB combines three things in one package:

  • A language designed for numerical work. Arithmetic works on whole arrays at once, so you rarely write loops for basic math.
  • An environment: a command window where you type and see results immediately, an editor, a variable inspector and a built-in help system.
  • A large library of functions for linear algebra, statistics, plotting, optimization, signal processing and more. Extra areas such as machine learning, control design or symbolic math ship as separate paid add-ons called toolboxes. Simulink, a block-diagram tool for modeling dynamic systems, is another add-on.

MATLAB is a commercial product from MathWorks. Universities and companies buy licenses, and many engineering courses are taught with it. That is why so many textbooks, lab manuals and research scripts are written in MATLAB.

What Octave is

GNU Octave started as a companion for a chemical engineering textbook and grew into a full free project. It is designed so that much MATLAB code works unchanged. You get a command-line interpreter, an optional graphical interface, a plotting system and a large collection of numerical functions. Extra functionality comes as packages that you load with pkg load, much like MATLAB toolboxes but free.

Octave is a fine choice for learning, for teaching, and for running numerical code on a server without paying per seat. Its speed and some advanced features differ from MATLAB, and a few things exist in only one of them.

How compatible are they?

For the kind of programs you write in this tutorial, the two agree almost completely. The core language is the same: matrices, indexing, operators, control flow, functions, cell arrays, structures and most numerical routines.

The differences you will meet most often:

Topic MATLAB Octave
Comment character % % or #
Block ends end end, endif, endfor, ...
Double-quoted strings string objects char arrays with escape sequences
+= and ++ not supported supported
Tables, live scripts, Simulink yes (some need toolboxes) not core features
Functions inside script files allowed at the end of a script allowed anywhere, defined before use

You do not need to memorize this. The rule of thumb is simple: write plain % comments, end blocks with end, use single quotes for text when you want portable code, and avoid the extras. A later lesson, MATLAB, Octave and Python Compared, compares the languages in depth.

What people use them for

Typical jobs look like this:

  • Read measurements from a file, remove bad values and plot the result.
  • Solve systems of equations or fit a line or curve through noisy data.
  • Simulate a physical system, for example a spring, a circuit or two competing animal populations.
  • Filter an audio signal or look at its frequency content with a Fourier transform.
  • Treat an image as a matrix of brightness values and sharpen it or detect edges.
  • Prototype an algorithm before turning it into C code or a product.

The same ideas appear in Python's NumPy library, R and Julia. If you already know one of them, MATLAB will feel familiar; if you do not, learning MATLAB teaches you array thinking that carries over everywhere.

How this tutorial shows code

This website runs code in your browser for languages such as Python, SQL and JavaScript. MATLAB and Octave are not among them: neither can be loaded into a web page, and MATLAB cannot be redistributed at all. So this tutorial uses two kinds of code blocks, and it always tells you which is which.

Read-only MATLAB/Octave blocks show the real language. You read them, and you can copy them into MATLAB or Octave on your own computer. The output printed under them is what the real program shows.

MATLAB
A = [1 2; 3 4];
B = A * 2

Real MATLAB prints:

TEXT
B =

     2     4
     6     8

Live Python stand-ins are editable <TryIt> blocks. They use NumPy, SciPy and matplotlib to reproduce the same matrix operations and plots, so you can experiment right here. They are not MATLAB. Where a difference matters, for example Python counting from 0 while MATLAB counts from 1, the text points it out.

Be honest about what is real: a stand-in proves that the mathematics works the way the lesson claims. It does not prove that a MATLAB command has exactly that spelling. Always trust the read-only MATLAB blocks for syntax and the TryIts for experimenting with the numbers.

Here is the first stand-in. The MATLAB version of this program is just x = A \ b, with a backslash. In NumPy the same job is done by np.linalg.solve.

MATLAB
A = [2 1; 1 3];
b = [5; 10];
x = A \ b
Python Solve a linear system (stand-in for A \ b)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Two equations, two unknowns, one line. That compactness is the main reason scientists like the language. The second stand-in shows the operator that confuses beginners most. In MATLAB, * is true matrix multiplication and .* multiplies element by element. In NumPy it is the other way round: @ is the matrix product and * works element by element.

Python Matrix product vs element-wise product

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You will meet this difference again in Arithmetic: Matrix vs Element-wise.

Getting the real thing

If you want to run real code while you follow along:

  • Octave is free for Windows, macOS and Linux. Install it, start it, and a command window with a prompt appears.
  • MATLAB needs a license. Many universities provide one, and MathWorks offers a limited browser-based option and trial versions.

Everything in the early lessons works in both. Where a lesson uses a feature that only one of them has, it says so.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the name MATLAB stand for?

    MATLAB is short for matrix laboratory. The language was built around matrices, and even a single number is a 1-by-1 matrix.
  2. 2. How does GNU Octave relate to MATLAB?

    Octave is an independent free program designed to be largely compatible with MATLAB, so most beginner code runs in both.
  3. 3. On this site, what is a Python TryIt in a MATLAB lesson?

    MATLAB and Octave cannot run in the page, so the live editors use Python libraries to reproduce the same operations. The read-only MATLAB blocks show the real syntax.
  4. 4. Which pair is correct for matrix multiplication?

    In MATLAB A * B is the matrix product and A .* B is element-wise. NumPy reverses the roles: A @ B is the matrix product and A * B is element-wise.

Summary

  • MATLAB is a commercial numerical computing environment where every value is a matrix.
  • GNU Octave is free and runs most MATLAB code; extras live in toolboxes (MATLAB) or packages (Octave).
  • Typical uses are data analysis, linear algebra, simulation, signals, images and plotting.
  • This tutorial shows real MATLAB/Octave code as read-only blocks and uses Python stand-ins you can edit and run.
  • Stand-ins reproduce the math, not the syntax, so watch for differences such as * versus @.

Next, see how to work with the program in The Desktop, Command Window and Scripts.