Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

MATLAB & GNU Octave  Module 1 – Start here: MATLAB, Octave and a working setup

MATLAB and GNU Octave: one language, two tools

What MATLAB and GNU Octave share, how their licences, releases and add-ons differ, which to choose for a course or lab, and how code tells them apart.

  • Beginner
  • 15 minutes
  • Examples run with octave 11.3.0 and Python 3.14.8
  • By MySmartCoPilot
Free lesson, Pro answers: 15 minutes
Free: the whole lesson. With a pass: the model answers to its 2 interview questions.

What you will learn

  • Explain what MATLAB and GNU Octave share and how their licences, releases and add-ons differ
  • Choose Octave, licensed MATLAB or MATLAB Online (basic) for a given course, lab or research task
  • Detect at run time whether code is running in Octave or MATLAB
  • Read this track's labels for portable, Octave-only and MATLAB-only features
What you’ll learn

What you will learn

  • Explain what MATLAB and GNU Octave share and how their licences, releases and add-ons differ
  • Choose Octave, licensed MATLAB or MATLAB Online (basic) for a given course, lab or research task
  • Detect at run time whether code is running in Octave or MATLAB
  • Read this track's labels for portable, Octave-only and MATLAB-only features
On this page

A twelve-line script that solves for the three currents of a resistor network prints 2.64, 0.60 and −0.56 amperes in MATLAB, and the same three numbers in GNU Octave. One language runs in two programs: MATLAB, a product of MathWorks that needs a licence for full use, and Octave, free software that anyone may install, change and share.

Below you see that script run in Octave, what the two programs share and where their licences, releases and add-ons part ways; you choose one for a course, a lab or a research task, make a script report which program is running it, and learn the labels this track puts on code that works in only one of them.

One script runs unchanged in both programs

Here is the script. R holds the resistances of three loops of a circuit in ohms and V the source voltages in volts. The backslash in R \ V solves the linear system: A set of linear equations solved together, written in matrix form as A*x = b. In MATLAB and Octave, x = A \ b solves it without forming an inverse. R*I = V for the currents. A for loop prints each current with fprintf, and max with two outputs returns the largest value and its position:

same_code_both.m: three loop currents M · same_code_both.m
% same_code_both.m: the three loop currents of a resistor network.
% Resistances in ohms, sources in volts. Runs unchanged in MATLAB and Octave.
R = [ 10  -4   0
      -4  12  -6
       0  -6  15 ];
V = [24; 0; -12];
I = R \ V;                     % solve R*I = V for the currents
for k = 1:numel(I)
  fprintf('Loop %d: %6.2f A\n', k, I(k));
end
[largest, loop] = max(abs(I));
fprintf('Largest current: %.2f A, in loop %d\n', largest, loop);

Octave 11.3 ran it from a terminal. The first line of the output names the Octave that ran it, and each line after $ is a command you would type yourself:

same_code_both.m, run with GNU Octave 11.3.0 Python · same_code_session.py
from session import run, version

version()
run("""
octave-cli same_code_both.m
""")

Output

# GNU Octave (aarch64-apple-darwin25.4.0) version 11.3.0
$ octave-cli same_code_both.m
Loop 1:   2.64 A
Loop 2:   0.60 A
Loop 3:  -0.56 A
Largest current: 2.64 A, in loop 1

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 same_code_session.py

MATLAB runs the same file without a change, because every line of it belongs to the language the two programs share. The Octave project describes its language as “mostly compatible with Matlab”, and the shared part is large:

  • matrices written in brackets, indexing with parentheses, and the colon, as in 1:numel(I);
  • the arithmetic and comparison operators, among them \ for linear systems and ~= for “not equal”;
  • if, for, while and switch blocks, each closed with end;
  • scripts and function files ending in .m, and comments that start with %;
  • text in single quotes, cell arrays and structs;
  • most built-in functions, from sum and max to inv and fprintf.

A course written for MATLAB that keeps to this part can be followed in Octave from the first day, and this track teaches this part first.

System of Equations Solver Enter 10x − 4y = 24, −4x + 12y − 6z = 0 and −6y + 15z = −12: the exact answer, 66/25, 3/5 and −14/25, is the 2.64, 0.60 and −0.56 above.

Checkpoint

Check: The language both programs share

  1. Question 1 of 2 In same_code_both.m, what does I = R \ V compute?

    Choose one answer.

    A hint

    The comment on that line says which equation it solves.

    Show the answer: Question 1 of 2

    Answer: The currents I for which R*I equals V

    R \ V solves R*I = V for I. With the three loop equations it gives 2.64, 0.60 and −0.56 amperes in both programs, as the run shows.

  2. Question 2 of 2 Which line of same_code_both.m would MATLAB reject?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: None of them

    The script keeps to the shared language: matrices in brackets, the backslash, a for loop closed with end, % comments and fprintf. That is why it runs unchanged in MATLAB and Octave.

Licences, releases and add-ons set the two apart

The two programs part ways outside the language. Four differences decide most choices:

Difference MATLAB GNU Octave
Made by MathWorks The Octave Project Developers
Licence Commercial: full use needs a licence Free software: the GNU GPL, version 3 or later
Releases A year and a letter: R2026a, R2026b Numbers: 11.1.0, 11.2.0, 11.3.0
Add-ons Toolboxes and Simulink, products of their own About 145 packages, installed with pkg

Octave reports its own licence and version, and lists the packages installed, none in this Homebrew installation:

Octave's licence, version and packages, typed at its prompt Python · about_session.py
from session import prompt, version

version()
prompt("about_octave.m")

Output

# GNU Octave (aarch64-apple-darwin25.4.0) version 11.3.0
$ octave-cli --quiet
octave:1> license()
ans = GNU General Public License v3+
octave:2> OCTAVE_VERSION
ans = 11.3.0
octave:3> pkg list
no packages installed.

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 about_session.py

Licence. license() answers GNU General Public License v3+. The GNU GPL: The GNU General Public License, the free-software licence of GNU Octave (version 3 or later): anyone may run, study, change and share the program, and copies passed on keep those freedoms. lets anyone run, study, change and share Octave, and every copy passed on carries the same freedoms. MATLAB is a MathWorks product: MATLAB Online (basic) costs nothing, and everything beyond it opens with a licence from a school, an employer or a purchase.

Releases. MathWorks names its releases by year and letter, two a year, such as R2025a, R2025b, R2026a and R2026b. Octave numbers them: 11.1.0 began version 11, and 11.2.0 and 11.3.0 brought fixes. 11.3.0 came four days after 11.2.0 to repair a library version number, and Octave’s news for version 11 tells users of 11.2.0 to update to 11.3.0. Every example in this track ran on Octave 11.3.0.

Add-ons. A MATLAB toolbox: A MathWorks product that adds functions to MATLAB for one field, such as signal processing or control systems. Code that calls its functions runs only where it is installed., such as the Signal Processing Toolbox, adds functions for one field, and MathWorks lists each toolbox as a product of its own, as it does Simulink, its environment for block-diagram models. Code that calls a toolbox function runs only where that toolbox is installed. Octave’s add-ons are Octave package: An add-on for GNU Octave, such as control or signal, listed in the Octave Packages index. pkg list shows the installed packages, and a new installation has none., such as control and signal, listed in the Octave Packages index: pkg list shows what is installed, and pkg load makes an installed package’s functions available. The Homebrew installation above has none; the Windows installers from octave.org come with several packages already installed.

Not affiliated

MySmartCoPilot is not affiliated with MathWorks or with the GNU Octave project. MATLAB and Simulink are registered trademarks of The MathWorks, Inc.

Checkpoint

Check: Licences, releases and add-ons

  1. Question 1 of 2 What does license() report in GNU Octave 11.3?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: GNU General Public License v3+

    In the run, license() answered "GNU General Public License v3+": Octave is released under the GNU GPL, version 3 or later, which lets anyone run, study, change and share it.

  2. Question 2 of 2 A lab script calls a function from MATLAB's Signal Processing Toolbox. Where does it run as written?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: In MATLAB, wherever that toolbox is installed

    MathWorks lists each toolbox as a product of its own, so a script that calls one runs where that toolbox is installed. Octave's packages are separate add-ons with their own functions.

Choosing Octave, licensed MATLAB or MATLAB Online

Three ways of running the language fit three kinds of work:

  • GNU Octave on your computer costs nothing and has no limits of time or network. It runs the shared language, so it suits most courses, assignments and research scripts that do not need Simulink or a toolbox.
  • MATLAB with a licence is the full product, on the desktop and online. It is the one to use when your school, lab or employer provides a licence, or when the work needs Simulink or a toolbox.
  • MATLAB Online (basic) is MATLAB in a web browser, at no cost, with Simulink and nine toolboxes. MathWorks limits it to 20 hours a month and 15 minutes of continuous compute, with 5 GB of storage in MATLAB Drive.

Answer the three questions below for a course, a lab or a project of yours. The table marks the options that fit, with the reason in every cell:

Interactive · answer and compare Which way of running the language fits your work? Answer three questions about a course, a lab or a project of yours. Every option is shown as it is until you answer, then the table marks the ones that fit and says why.
Does your school, lab or employer give you a MATLAB licence?
Does the work need Simulink, or a toolbox that Octave's packages do not cover?
Will you run jobs longer than a few minutes, or work without a network?

Answer the questions above: the table then marks what fits your case and says why the rest does not.

GNU Octave, licensed MATLAB and MATLAB Online (basic) against five things a course or project can need
Option Needs no licence Works without a network Long runs Toolboxes and Simulink Runs MATLAB-only code
GNU Octave on your computer Good free software under the GNU GPL, version 3 or later Good installed on your computer; no account and no network needed Good runs as long as your computer does Mixed packages such as control and signal; no Simulink Mixed the shared language runs; string arrays, tables and newer syntax do not
MATLAB with a licence Poor needs a licence from a school, an employer or a purchase Good licensed users get the desktop version as well as MATLAB Online Good desktop runs are limited by your computer; online, 90 minutes at a stretch Good Simulink and the toolboxes the licence covers Good it is MATLAB, so MATLAB-only code runs
MATLAB Online (basic) Good no cost, with a MathWorks account Poor online only, in a web browser Poor 20 hours a month, and at most 15 minutes of continuous compute Mixed MATLAB, Simulink and nine toolboxes Good it is MATLAB, so MATLAB-only code runs
How the answers decide
  • “Does your school, lab or employer give you a MATLAB licence?” No, or I am not sure: rules out MATLAB with a licence. Full MATLAB opens only with a licence linked to your MathWorks account. Without one, the free choices are Octave and the basic plan.
  • “Does the work need Simulink, or a toolbox that Octave's packages do not cover?” Yes, it needs one of them: rules out GNU Octave on your computer. Simulink and toolbox functions run only in MATLAB with that product. Octave packages cover some fields, not Simulink.
  • “Will you run jobs longer than a few minutes, or work without a network?” Yes, long jobs or no network: rules out MATLAB Online (basic). The basic plan runs in a browser, for 20 hours a month and at most 15 minutes of continuous compute.
  • “Does the work need Simulink, or a toolbox that Octave's packages do not cover?” No, the core language is enough and “Will you run jobs longer than a few minutes, or work without a network?” No, short sessions online are fine: adds a caveat to MATLAB Online (basic). Octave covers the shared language with no limits; the basic plan is still a useful second check that code also runs in MATLAB.

In short: Octave for most coursework and scripts, a licensed MATLAB when Simulink, a toolbox or a lab’s licence is part of the work, and the basic plan for short sessions in MATLAB itself, such as checking that your Octave script also runs there.

Planning a long job on the basic plan

A parameter sweep that computes for an hour does not fit MATLAB Online (basic), which MathWorks limits to 15 minutes of continuous compute and 20 hours a month. Run long jobs in Octave or in a licensed MATLAB, and keep the basic plan for short checks.

Checkpoint

Check: Choosing a way to run it

  1. Question 1 of 2 A first-year course grades short Simulink models built during lab sessions. The students have no MATLAB licence. Which option fits?
    Show the answer: Question 1 of 2

    Answer: MATLAB Online (basic)

    Simulink rules Octave out, and the missing licence rules out a licensed MATLAB. MATLAB Online (basic) includes Simulink, and short sessions stay within its limits.

  2. Question 2 of 2 Your thesis needs a parameter sweep that computes for six hours with core functions only, and you have no licence. Which option fits?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: GNU Octave on your computer

    Without a licence the choice is between Octave and the basic plan, and the basic plan allows 15 minutes of continuous compute. Octave runs for as long as your computer does.

A script can tell which program is running it

Sometimes code must behave differently in the two programs, for example to call a function that only one of them has. The Octave manual’s test asks whether a built-in function called OCTAVE_VERSION exists. Octave has one and MATLAB does not:

which_am_i.m: which program is running? M · which_am_i.m
% which_am_i.m: which program is running this code?
code = exist('OCTAVE_VERSION', 'builtin');
isOctave = code ~= 0;
if isOctave
  tool = 'GNU Octave';
else
  tool = 'MATLAB';
end
fprintf('exist(''OCTAVE_VERSION'', ''builtin'') returned %d\n', code);
fprintf('Running in %s, version %s\n', tool, version());
fprintf('Built for %s\n', computer());
which_am_i.m, run with GNU Octave 11.3.0 Python · which_am_i_session.py
from session import run, version

version()
run("""
octave-cli which_am_i.m
""")

Output

# GNU Octave (aarch64-apple-darwin25.4.0) version 11.3.0
$ octave-cli which_am_i.m
exist('OCTAVE_VERSION', 'builtin') returned 5
Running in GNU Octave, version 11.3.0
Built for aarch64-apple-darwin25.4.0

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 which_am_i_session.py

In Octave, exist('OCTAVE_VERSION', 'builtin') returned 5, the code exist uses for a built-in function, so the script took its Octave branch. Step through both branches, with MATLAB’s values taken from MathWorks’ documentation:

Interactive · step by step How which_am_i.m tells Octave from MATLAB Step through the one question the script asks, then the branch each program takes and what it prints.
How which_am_i.m tells Octave from MATLAB, step 6 of 6. Showing Look up OCTAVE_VERSION, In Octave: 5 (tool = 'GNU Octave'), In MATLAB: 0 (tool = 'MATLAB'), Print the tool (MATLAB 26.2.0… (R2026b)). In focus: Print the tool.OctaveMATLABLook up OCTAVE_VERSIONexist(name, 'builtin')In Octave: 5tool = 'GNU Octave'In MATLAB: 0tool = 'MATLAB'Print the toolMATLAB 26.2.0… (R2026b)

The drawing shows the whole scene; its 6 steps are listed below.

Every step as text
  1. One question. The script first asks whether a built-in function called OCTAVE_VERSION exists. With 'builtin' as its second argument, exist looks at built-in functions only, never at variables or files.
  2. Octave answers 5. Octave has a built-in function of that name, so exist returns 5, its code for a built-in function. code ~= 0 is true, so isOctave is true.
  3. The Octave branch. The if block takes its first branch and sets tool to 'GNU Octave'.
  4. The report. fprintf prints the code, the tool with the version that version() returns, 11.3.0 here, and computer(), the platform the program was built for.
  5. MATLAB answers 0. MATLAB has no built-in function of that name, and MathWorks documents 0 as the answer for a name that is not found. code ~= 0 is false, so isOctave is false.
  6. The MATLAB branch. The else branch sets tool to 'MATLAB', and version() returns MATLAB's own version text, which MathWorks' documentation shows as '26.2.0.3341813 (R2026b)'.

MathWorks documents 0 as the answer for a name that is not found, so in MATLAB isOctave is false and the script reports MATLAB with its own version text. The second argument, 'builtin', makes the test safe: without it, exist also counts variables and files, so a variable or a file called OCTAVE_VERSION could make MATLAB look like Octave.

Key idea

exist('OCTAVE_VERSION', 'builtin') ~= 0 is true in Octave and false in MATLAB, so one line tells a script which program runs it; branch on that test, never on a version string.

Checkpoint

Check: Telling Octave from MATLAB in code

  1. Question 1 of 2 What number did exist('OCTAVE_VERSION', 'builtin') return in Octave 11.3?

    Type a number.

    A hint

    Look at the first line that which_am_i.m printed.

    Show the answer: Question 1 of 2

    Answer: 5

    5 is the code exist uses for a built-in function, and Octave has a built-in function called OCTAVE_VERSION. In MATLAB, where no such function exists, the answer is 0.

  2. Question 2 of 2 Why does which_am_i.m pass 'builtin' as the second argument of exist?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: So a variable or a file called OCTAVE_VERSION cannot make MATLAB look like Octave

    exist with one argument also reports variables (1) and files (2). Limiting it to built-in functions means only Octave's own OCTAVE_VERSION can make the test true.

Labels mark code that runs in only one program

Octave accepts some code that MATLAB rejects. This script computes the same currents with five Octave-only shortcuts: a # comment, printf, +=, endfor and endif, and != for “not equal”. It runs in Octave, and Octave can warn about some of its own extensions:

octave_only.m: the same currents with Octave-only shortcuts M · octave_only.m
# octave_only.m: the same currents, written with Octave-only shortcuts.
R = [10 -4 0; -4 12 -6; 0 -6 15];
V = [24; 0; -12];
I = R \ V;
total = 0;
for k = 1:numel(I)
  printf("Loop %d: %6.2f A\n", k, I(k));
  total += I(k);
endfor
if total != 0
  printf("Sum of the loop currents: %.2f A\n", total);
endif
check_extensions.m: the same run with Octave's warning switched on M · check_extensions.m
% check_extensions.m: runs octave_only.m with Octave's warning about its own
% language extensions switched on, then switches the warning off again.
warning('on', 'Octave:language-extension');
octave_only
warning('off', 'Octave:language-extension');
Octave-only code, a MATLAB-only call and quotes, GNU Octave 11.3.0 Python · extensions_session.py
from session import prompt, run, version

version()
run("""
octave-cli octave_only.m
octave-cli check_extensions.m
""")
prompt("name_value.m")
prompt("quotes.m")

Output

# GNU Octave (aarch64-apple-darwin25.4.0) version 11.3.0
$ octave-cli octave_only.m
Loop 1:   2.64 A
Loop 2:   0.60 A
Loop 3:  -0.56 A
Sum of the loop currents: 2.68 A
$ octave-cli check_extensions.m
warning: Octave language extension used: += used as operator near line 8 of file octave_only.m
warning: called from
    check_extensions at line 4 column 1

warning: Octave language extension used: != used as operator near line 10 of file octave_only.m
warning: called from
    check_extensions at line 4 column 1

Loop 1:   2.64 A
Loop 2:   0.60 A
Loop 3:  -0.56 A
Sum of the loop currents: 2.68 A
$ octave-cli --quiet
octave:1> parts = strsplit('a,,b', ',', CollapseDelimiters=false);
octave:2> numel(parts)
ans = 3
octave:3> who
Variables visible from the current scope:

CollapseDelimiters  ans                 parts

$ octave-cli --quiet
octave:1> numel("a\tb")
ans = 3
octave:2> numel('a\tb')
ans = 4

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 extensions_session.py

The first run printed the currents. In the second, the warning Octave:language-extension flagged += and != but said nothing about the # comment, printf, endfor or endif, so the warning finds some extensions, not all of them. The third part goes the other way: CollapseDelimiters=false is MATLAB’s way to pass a name-value argument, but Octave 11.3 read it as an assignment, so who lists a new variable called CollapseDelimiters. The last part counts characters: inside double quotes Octave turned \t into one tab, so "a\tb" has 3, while 'a\tb' keeps all 4.

This track labels such code in the text and in the titles of examples: Octave-only, MATLAB-only, or Differs when both programs run it with different results:

Code Label In the other program
% note, %{ … %} Portable The same in both
# note, #{ … #} Octave-only MATLAB comments start with %
x ~= y, ~ok Portable The same in both
x != y, !ok Octave-only In MATLAB ! runs an operating-system command
x += 1, k++ Octave-only MATLAB assigns with = only
endif, endfor Octave-only MATLAB closes every block with end
printf("…") Octave-only MATLAB has fprintf
"a\tb" Differs Octave: text with \t as a tab, 3 characters; MATLAB: a string
f(x, Name=value) MATLAB-only Octave 11.3: assigns Name, passes only the value

Code without a label is portable, and examples run on Octave unless their title says otherwise. MATLAB behaviour that these pages describe comes from MathWorks’ documentation.

Trusting Octave's warning to find every extension

warning('on', 'Octave:language-extension') flagged += and != in the run above, but not #, printf, endfor or endif. Before you hand a script to someone who uses MATLAB, check it against the table, or run it in MATLAB Online (basic).

Checkpoint

Check: Portable, Octave-only and MATLAB-only code

  1. Question 1 of 2 How does this track label the line # check the currents?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: Octave-only

    A comment that starts with % works in both programs. A comment that starts with # is an Octave extension, so it is labelled Octave-only.

  2. Question 2 of 2 In Octave 11.3, numel("a\tb") is 3 and numel('a\tb') is 4. Why?

    Choose one answer.

    A hint

    Count the characters, and remember what \t means.

    Show the answer: Question 2 of 2

    Answer: Octave turns \t into one tab character inside double quotes, but keeps the backslash and the t inside single quotes

    In Octave, "a\tb" is char text in which \t has become a tab: 3 characters. 'a\tb' keeps the backslash: 4 characters. In MATLAB, double quotes create a string instead, so the row is labelled as differing.

Practise: which program, which label?

Two tasks wait for the next lesson’s installation. Save which_am_i.m and same_code_both.m, run both, and set your output beside the recorded runs: only the “Built for” line should name a different platform, and the three currents must not change. With access to MATLAB or MATLAB Online (basic), run which_am_i.m there as well and see the else branch report MATLAB.

Five ideas carry this lesson: the shared language, what sets the two programs apart, choosing one, the run-time test and the labels. The practice session below starts with whichever of them your answers show to be weakest, asks one question at a time and explains each answer the moment you give it:

Practice that adapts to you

Practise this lesson

15 questions about 5 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 15 Which of these belong to the language that MATLAB and Octave share? Choose every one that does.

    Choose every answer that is right.

    Show the answer: Question 1 of 15

    Answer:

    • \ to solve a linear system
    • end at the close of a for loop
    • % at the start of a comment

    %, end and the backslash are part of the shared language. endfor and += are Octave-only shortcuts that MATLAB rejects.

  2. Question 2 of 15 What does this print, in MATLAB and in Octave?

    Read the code, then choose one answer.

    [m, k] = max([3 -7 5]);
    fprintf('%d %d\n', m, k);
    Show the answer: Question 2 of 15

    Answer: 5 3

    max with two outputs returns the largest value and its position: 5 at position 3. This is the same call the circuit script makes with max(abs(I)).

  3. Question 3 of 15 A course's MATLAB scripts use only matrices, for loops, % comments, inv and fprintf. You have Octave only. What should you expect?

    Choose one answer.

    Show the answer: Question 3 of 15

    Answer: They run in Octave unchanged

    Matrices, loops, % comments, inv and fprintf all belong to the shared language, so the scripts run in Octave as written.

  4. Question 4 of 15 Which of these is a MATLAB release name, written the way MathWorks writes it?

    Choose one answer.

    Show the answer: Question 4 of 15

    Answer: R2026b

    MathWorks names its releases by year and letter, two a year, such as R2024a and R2024b. Octave uses version numbers such as 11.3.0.

  5. Question 5 of 15 What does pkg list print in an Octave 11.3 installation that has no packages yet, such as the Homebrew one of the recorded run?

    Choose one answer.

    Show the answer: Question 5 of 15

    Answer: no packages installed.

    The run showed "no packages installed." pkg is part of Octave; packages such as control or signal are installed separately, though the Windows installers from octave.org come with several already installed.

  6. Question 6 of 15 A lab computer runs Octave 11.2.0. Following Octave's own news for version 11, what should the lab do?

    Choose one answer.

    Show the answer: Question 6 of 15

    Answer: Update to 11.3.0, which fixed a library version number that 11.2.0 got wrong

    11.3.0 came four days after 11.2.0 and fixed the version number of the liboctinterp library, and the news for Octave 11 advises updating to it.

  7. Question 7 of 15 What does MathWorks include in MATLAB Online (basic)?

    Choose one answer.

    Show the answer: Question 7 of 15

    Answer: MATLAB, Simulink and nine toolboxes, for 20 hours a month

    The basic plan is MATLAB in a web browser at no cost, with Simulink and nine toolboxes, 20 hours a month, 15 minutes of continuous compute and 5 GB of storage.

  8. Question 8 of 15 You analyse sensor readings at a field station with no internet, using only core functions. Which option fits?

    Choose one answer.

    Show the answer: Question 8 of 15

    Answer: GNU Octave on your computer

    With no network, MATLAB Online is out. Octave runs on your computer with no account and no licence.

  9. Question 9 of 15 Your lab has a campus MATLAB licence, and your thesis runs three-hour simulations that use the Control System Toolbox. Which option fits best?

    Choose one answer.

    Show the answer: Question 9 of 15

    Answer: MATLAB with the campus licence

    The toolbox needs MATLAB, and three-hour runs need more than the basic plan's 15 minutes. The campus licence gives you both.

  10. Question 10 of 15 By MathWorks' documentation, what does exist('OCTAVE_VERSION', 'builtin') return in MATLAB?

    Type a number.

    Show the answer: Question 10 of 15

    Answer: 0

    MATLAB has no built-in function called OCTAVE_VERSION, and MathWorks documents 0 for a name that is not found. So the test is false in MATLAB and true in Octave, where it returns 5.

  11. Question 11 of 15 A colleague tests strcmp(version(), '11.3.0') to decide whether code runs in Octave. What is wrong with that?

    Choose one answer.

    Show the answer: Question 11 of 15

    Answer: It fails as soon as Octave is updated, while the built-in test keeps working

    A version string identifies one release, not the program. The built-in test is true in every Octave and false in MATLAB, so it keeps working after updates.

  12. Question 12 of 15 By MathWorks' documentation of exist, what is isOctave after these two lines run in MATLAB?

    Read the code, then choose one answer.

    OCTAVE_VERSION = '11.3.0';
    isOctave = exist('OCTAVE_VERSION') ~= 0;
    Show the answer: Question 12 of 15

    Answer: true, because exist finds the variable and returns 1

    exist with one argument counts variables, and returns 1 for one, so MATLAB would pass for Octave. With 'builtin', exist would return 0 and the test would stay false.

  13. Question 13 of 15 How is endif labelled in this track?

    Choose one answer.

    Show the answer: Question 13 of 15

    Answer: Octave-only

    endif is an Octave extension. Code meant for both programs closes an if block with end.

  14. Question 14 of 15 Which of these lines runs unchanged in MATLAB?

    Choose one answer.

    Show the answer: Question 14 of 15

    Answer: if x ~= 0

    Only ~= is portable. !=, += and # are Octave extensions that MATLAB rejects.

  15. Question 15 of 15 In Octave 11.3, which variables exist after parts = strsplit('a,,b', ',', CollapseDelimiters=false); runs in a new session?

    Choose one answer.

    Show the answer: Question 15 of 15

    Answer: parts and CollapseDelimiters

    The run showed who listing CollapseDelimiters next to parts: Octave 11.3 treats Name=value in a call as an assignment and passes only the value. That is why the track labels Name=value calls MATLAB-only.

Interview questions

Warm-up: what is the difference between MATLAB and GNU Octave?

Both run the same core language: matrices, indexing, operators, control flow, scripts and functions, so a script that keeps to it, such as one that solves a resistor network with R \ V, runs unchanged in either. MATLAB is a MathWorks product: full use needs a licence, its add-ons are toolboxes and Simulink, and its releases are named R2026a, R2026b and so on. Octave is free software under the GNU GPL version 3 or later, its add-ons are packages from the Octave Packages index, and its releases are numbered, such as 11.3.0. Newer MATLAB features, such as string arrays, tables and Name=value calls, are missing or behave differently in Octave, and Octave accepts extensions, such as # comments, += and endif, that MATLAB rejects. Code can test which one runs it with exist('OCTAVE_VERSION', 'builtin').

Model answers open with any pass: ₹79 for 1 week ($2.99), one payment that never renews.

  1. Fresher to mid

    You set up the computing for a first-year engineering course of 120 students: Octave on their laptops, a campus MATLAB licence, or MATLAB Online (basic). Which do you choose, and what do you check before deciding?

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Mid to senior

    Your research group has 40 MATLAB scripts and must run them on new laptops that have only GNU Octave. How do you find what breaks, fix it, and keep the scripts working in both programs afterwards?

    Model answer, Pro. First step and follow-ups

Key takeaways

  • MATLAB and GNU Octave run one shared language, so a script of matrices, \, loops, % comments and fprintf, such as the three-loop circuit solver, prints the same results in both.
  • MATLAB is a MathWorks product whose full use needs a licence, named by year and letter (R2026b); Octave is free software under the GNU GPL version 3 or later, numbered by version (11.3.0), with packages instead of toolboxes.
  • Octave suits most coursework and scripts, a licensed MATLAB suits work that needs Simulink, a toolbox or a lab’s licence, and MATLAB Online (basic) suits short sessions within its 20 hours a month and 15-minute runs.
  • exist('OCTAVE_VERSION', 'builtin') returns 5 in Octave and 0 in MATLAB, so a script can branch on it; the 'builtin' argument keeps a variable or a file of that name from fooling the test.
  • This track marks code as Octave-only or MATLAB-only, and Octave’s Octave:language-extension warning finds some of its own extensions, such as += and !=, but not # comments, printf or endif.

Terms in this lesson

GNU GPL
The GNU General Public License, the free-software licence of GNU Octave (version 3 or later): anyone may run, study, change and share the program, and copies passed on keep those freedoms.
linear system
A set of linear equations solved together, written in matrix form as A*x = b. In MATLAB and Octave, x = A \ b solves it without forming an inverse.
Octave package
An add-on for GNU Octave, such as control or signal, listed in the Octave Packages index. pkg list shows the installed packages, and a new installation has none.
toolbox
A MathWorks product that adds functions to MATLAB for one field, such as signal processing or control systems. Code that calls its functions runs only where it is installed.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.