24
$\begingroup$

I want to learn MATLAB programming so that I can conduct some researh/analysis on my own and also, so that I can study/modify some MATLAB scripts that I have found online etc.

However, the problem is that I can't afford MATLAB. GNU Octave, from what I have heard, is quite MATLAB compatable. The challenge with Octave though is that the documentation is very sparse.

So MATLAB on one hand, is prohibitively expensive (-ve), but has lots of good documentation, tutorials and scripts online (+), while Octave is free (as in beer), even though (understandably) it lacks comprehensive documentation, etc.

I am thinking of downloading and installing Octave, but using MATLAB documentation (and scripts) to help me get going. I am aware that there are some differences between Octave and MATLAB - what I'm trying to work out is whether the differences are large enough to thwart my efforts to (effectively) "learn MATLAB by using Octave".

Any constructive feedback welcome.

$\endgroup$
5
  • 3
    $\begingroup$ Welcome, Homunculus. We're less than two months old and don't yet have a lot of tags. I've added the octave tag for you. $\endgroup$ Commented Jan 22, 2012 at 19:35
  • $\begingroup$ another option, if your goal is to just to use a computational software for your personal use is Mathematica. The full complete version is available for personal use less than $300. I do not know if this is within your budget or not. But for what one gets for this (same version as the full commercial version), it is worth it I would think. note: If you are student, then Matlab and Mathematica are also available for students for about the same price. $\endgroup$
    – Nasser
    Commented Jan 27, 2012 at 7:48
  • 1
    $\begingroup$ In a word, yes. The differences between the languages are pretty small. Documentation for Matlab is available for free on the Internet from the Mathworks.com (the makers of Matlab). The main thing you'll miss is Matlab's GUI. A good GUI for Octave is hard to find. The development version of Octave has a GUI but is difficult to install. I installed QtOctave, which I got at outsch.org/2011/01/29/qtoctave-0-10-1-for-windows . It works OK, except there is always an error message at startup, and I can't terminate a process without killing Octave entirely. I use Notepad++... $\endgroup$ Commented Jul 15, 2013 at 22:49
  • $\begingroup$ ...instead of QtOctave's editor, and it seems to work better. Another thing, the differences between Octave and Matlab, such as they are, are extensively documented on free Web sites. $\endgroup$ Commented Jul 15, 2013 at 22:50
  • $\begingroup$ Since I don't have enough reputation to comment, I would like to add that a statement in the accepted answer: "Of course, there are features of MATLAB (particularly in the toolboxes, but Octave doesn't have those) " is completely wrong. Octave has a rich set of packages at Octave-forge that include every package function of Matlab's that I've ever needed (I work in image processing and optimization for medical images, and need quite a few toolboxes / packages). Also, the accepted answer does not address a major issue, which is that no code the questioner writes will be usable by labs or indivi $\endgroup$
    – barnhillec
    Commented Oct 26, 2016 at 10:10

12 Answers 12

24
$\begingroup$

Disclaimer: I sometimes get annoyed when somebody tries to tell me what they think I ought to do rather than answering the question I asked. But I'm going to take a risk and suggest an alternative to you.

I would suggest looking at Python's scientific computing packages: numpy, matplotlib, and scipy. Together, they provide you most of the core functionality of MATLAB (in some cases they give you more than MATLAB). They are free and open source, and nowadays may have a wider user base than Octave. Much of the scientific computing infrastructure in Python is supported by Enthought Inc., and I would recommend that you install their free Enthought Python Distribution, which includes all three packages I mentioned and more.

Of course, there are features of MATLAB (particularly in the toolboxes, but Octave doesn't have those) that Python lacks. But I use Python in combination with lower-level languages for most of my work, and it allows me to program in a language almost as convenient as MATLAB, interface with a host of useful packages that MATLAB doesn't have, and to run the same easy-to-read code on a supercomputer.

Edit: you may also want to try the Anaconda Python distribution from Continuum Analytics. There is a free version that includes all the above packages and much more.

$\endgroup$
7
  • 7
    $\begingroup$ It depends on whether Homunculus wants to learn MATLAB because they specifically need to learn MATLAB (for example, for a job), or they want to learn MATLAB to do scientific computing, in which case Python may be a better choice given the financial constraints. $\endgroup$ Commented Jan 22, 2012 at 21:36
  • 3
    $\begingroup$ @DavidKetcheson: I am actually using numpy and matplotlib (since I am familiar with Python). However, I keep coming accross a lot of MATLAB code, so I would like to be able to learn from the available MATLAB scripts etc (without having to fork out for the license fee). Besides its always good to have MATLAB programming as an extra feather in my cap - thats why I was thinking of learning MATLAB via the backdoor (using Octave). $\endgroup$ Commented Jan 27, 2012 at 13:28
  • $\begingroup$ +1 for Python here, it's also a real programming language :) Although I should say that I did start by learning MATLAB. $\endgroup$
    – boyfarrell
    Commented Mar 5, 2013 at 0:17
  • $\begingroup$ Octave is a Matlab clone with free license. Its language syntax is almost fully compatible. Python solves a very different problem than Matlab and Octave. Its syntax is much more complicated and verbose because the language is more versatile. For prototyping linear systems you would use Matlab or Octave, then for implementing production-ready software you would migrate to python / Java. Before switching from Matlab to Python or R, you should understand what you're getting into. $\endgroup$
    – FistOfFury
    Commented Jan 6, 2017 at 11:33
  • $\begingroup$ @FistOfFury I use pure Python3 for linear systems. For production ready software you usually go for either C/Fortran or embedded. $\endgroup$
    – percusse
    Commented Jan 6, 2017 at 14:23
18
$\begingroup$

GNU Octave is "mostly compatible with Matlab", certain subtleties means not all scripts are portable from MATLAB to Octave.

It is worth reading the documentation for the language and/or compatibility notes in the FAQs or on wikibooks. There are also porting notes.

Packages similar to MATLAB toolboxes exist, but you will need to check them out to work out how similar they are. Also there are attempts at conversion scripts that take care of the differences between the two languages, but to my knowledge none are perfect.

$\endgroup$
11
$\begingroup$

Yes you can learn MATLAB via Octave. But Octave syntax is less restrictive and more in line with modern scripting languages. MATLAB seems behind in this respect. See this wiki link MATLAB Programming/Differences between Octave and MATLAB

Another major difference to me were the availability of certain libraries for MATLAB but not for Octave.

$\endgroup$
9
$\begingroup$

For generally learning M-language programming and how MATLAB works, yes, Octave is just fine. If you need a particular toolbox as part of your work, though, and no one has implemented a free version of it, then you're out of luck.

A student edition of MATLAB isn't that expensive. If you're at a university, it's even possible that they have a site license. You should look into both possibilities.

$\endgroup$
7
$\begingroup$

I've used Octave and MATLAB interchangeably on the same pieces of code in the past; I've had no problems with compatibility. The main differences as far as I can tell are:

  1. MATLAB can be byte-compiled, and is slightly faster.
  2. Octave can use either # or % for comments, Matlab only uses %
  3. Octave produces much better plots.
$\endgroup$
9
  • 1
    $\begingroup$ I would be interested to hear, in what respect Octave produces much better plots (not that I particularly like the MATLAB plots...). $\endgroup$
    – Dirk
    Commented Jan 25, 2012 at 13:38
  • $\begingroup$ Octave uses gnuplot as a backend. It might be just that I like the gnuplot look more. The only specific thing I can think of is that I don't have to do anything special to get antialiasing; it's automatically enabled. $\endgroup$
    – Dan
    Commented Jan 25, 2012 at 19:31
  • 1
    $\begingroup$ My experience with Octave plotting has been mixed, and after learning a thing or two with MATLAB the quality of graphics I get out of it is now very good. Maybe you have some examples where Octave outperforms Matab for this? Aso, byte-compiled? Are you talking about the MATLAB coder? You can't just input arbitrary MATLAB code into that tool, and if I recall it is a rather expensive tool as well, certainly not available in a student licensed version. $\endgroup$ Commented Jan 12, 2013 at 20:50
  • $\begingroup$ Whoops, I see what you mean for the compilation. My fault. $\endgroup$ Commented Jan 12, 2013 at 20:56
  • $\begingroup$ I'm sorry but what does it mean by Matlab can be byte-compiled? $\endgroup$
    – user17915
    Commented Sep 27, 2013 at 5:03
6
$\begingroup$

It is indeed possible, especially if you use a GUI, such as GUIOctave. Another language that you might find useful because many packages have been written for it is R. There is also a GUI for the R language, called RStudio, and a translation document between R and MatLab.

$\endgroup$
5
$\begingroup$

Regarding your question:
I would say yes. Simply because the paradigms and principles are the same. The differences in the syntax are neglectable and can be summarized in a cheat sheet (in case you are working mainly with MATLAB one day).


Another suggestion for an alternative:
As a MATLAB alternative I'm using SciLab. It's free as Octave, has a decent community providing help and support and it's documentation is pretty good. The build-in documentation and help for functions is similar to MATLAB's one. (What I like most is the ability to execute the examples with one click). The syntax is similar to MATLAB as well.

Regarding the similarities and differences between SciLab and MATLAB, this document might be of interest for you: An Introduction to Scilab from a Matlab User's Point of View, Eike Rietsch, May 2010 (PDF).

Another plus for SciLab over MATLAB: Start-up and GUI is a lot faster. I haven't tried Octave yet.

$\endgroup$
2
  • 1
    $\begingroup$ I'm not a fan of Scilab, my first impression was that there were a lot of small differences in syntax and basic functions (relative to Matlab), but none of the awsome that python has to make up for the incompatibility. $\endgroup$
    – mdaoust
    Commented Jan 26, 2012 at 1:15
  • $\begingroup$ Hm... according to your comment and David Ketcheson answer it seems really worth trying out Python. $\endgroup$
    – Torbjörn
    Commented Jan 26, 2012 at 5:19
5
$\begingroup$

Practical example:

I use MATLAB at work, and I took Stanford's free online machine learning class last semester.

I did all the homework in octave.

I only noticed 2 differences (I was only using core functionality):

  • Octave is a little more flexible about what sorts of expressions can be indexed. So if you take advantage of that, your code won't be portable.
  • In my installation the pcolor() and image() plots don't work for reasonably sized arrays, like 1000x1000, small ones, like 50x50, work fine.
$\endgroup$
5
$\begingroup$

There are some subtle differences in Octave's interpretation of the MATLAB's programming language. Octave uses "endif" and "endwhile" to close if and while statements respectively. Octave also allows you to declare functions on the command line. It should, however, parse anything that MATLAB parses too, so if you stick to MATLAB's programming language, you should be fine.

Be aware that the biggest differences between the two programs is in the built-in functions that do most of the numerical heavy-lifting, e.g. "quad", "ode15s" and such. All of these functions should, however, be well documented when using the "help" command. There are also mailing lists for Octave should you have more specific questions that aren't covered by the online help.

$\endgroup$
1
  • 3
    $\begingroup$ Octave is more than happy to accept "end" for the end of both while loops and if statemtents. $\endgroup$
    – Bill Barth
    Commented Jan 22, 2012 at 20:26
4
$\begingroup$

Yes you absolutely can, I did. Much of the power out of MATLAB however does come with some of its hugely easy to use toolboxes and builtins which may or may not have equivalents in Octave.

Also be aware that while the base languages themselves are compatible (except for the newish OO features in MATLAB), Octave has a few 'additions' to the syntax, like being able to use "!=" for NEQ, and it also has some alternate default behaviors like how it parses inline functions. These are minor things that will cause Octave code not to run in MATLAB right off the bat unless you've taken care to avoid relying on that behavior.

Also MATLAB is a full computing environment, and not just a language that interfaces with optimized linear algebra routines. So what you learn out of Octave will only go so far. You will be functional in MATLAB if you are proficient with Octave, but you won't be as productive with MATLAB as you could be.

$\endgroup$
2
$\begingroup$

The best free language which has MATLAB-like syntax is Julia. It's also faster and has a more extensive package system (among other reasons why it's better...), but the linear algebra syntax is almost exactly the same (many algorithms you can translate to MATLAB by changing A[i] for indexing to A(i)). I believe it's the best language to learn right now, and you'll "accidentally know MATLAB" just by using it.

$\endgroup$
0
$\begingroup$

Yes, you can learn Matlab using Octave. Of course there are some limitations.

Octave and Matlab share a much of their syntax. The two are interchangeable in that respect. The experience in Matlab is more rich and user friendly, particularly when working with graphics, though Octave has a new graphical user interface (GUI) that is in beta. The two systems will likely converge further as the graphical environment for Octave improves.

There are a lot of free courses on Coursera that give you a free temporary Matlab student license for the duration of the course. Search for machine learning courses.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.