Differences between Octave and MATLAB

MatlabOctave

Matlab Problem Overview


I'm a programmer who knows Python, Ruby and some C who is trying to decide whether to learn GNU Octave or MATLAB. I know that they have a lot in common, but it isn't clear to me how similar the syntax is or even the data structures are. The above link shows several examples where they are syntactically similar or identical. Is this true for the whole language?

I am trying to learn the language in general to do more scientific computing, possibly using some image analysis libraries.

Additionally, is MATLAB worth the cost?

Matlab Solutions


Solution 1 - Matlab

Rather than provide you with a complete list of differences, I'll give you my view on the matter.

If you read carefully the wiki page you provide, you'll often see sentences like "Octave supports both, while MATLAB requires the first" etc. This shows that Octave's developers try to make Octave syntax "superior" to MATLAB's.

This attitude makes Octave lose its purpose completely. The idea behind Octave is (or has become, I should say, see comments below) to have an open source alternative to run m-code. If it tries to be "better", it thus tries to be different, which is not in line with the reasons most people use it for. In my experience, running stuff developed in MATLAB doesn't ever work in one go, except for the really simple, really short stuff -- For any sizable function, I always have to translate a lot of stuff before it works in Octave, if not re-write it from scratch. How this is better, I really don't see...

Also, if you learn Octave, there's a lot of syntax allowed in Octave that's not allowed in MATLAB. Meaning -- code written in Octave often does not work in MATLAB without numerous conversions. It's also not compatible the other way around!

I could go on: The MathWorks has many toolboxes for MATLAB, there's Simulink and its related products for which there really is no equivalent in Octave (yes, you'd have to pay for all that. But often your employer/school does that anyway, and well, it at least exists), proven compliance with several industry standards, testing tools, validation tools, requirement management systems, report generation, a much larger community & user base, etc., etc., etc. MATLAB is only a small part of something much larger. Octave is...just Octave.

So, my advice:

  • Find out if your school will pay for MATLAB. Often they will.
  • If they don't, and if you can scrape together the money, buy MATLAB and learn to use it properly. In the long run it's the better decision.
  • If you really can't get the money -- use Octave, but learn MATLAB's syntax and stay away from Octave-only syntax. (see note)

Why this last point? Because in the sciences, there are often large code bases entirely written in MATLAB. There are professors, engineers, students, professional coders, lots and lots of people who know all the intricate gory details of MATLAB, and not so much of Octave.

If you get a new job, and everyone in your new office speaks Spanish, it's kind of cocky to demand of everyone that they start speaking English from then on, simply because you don't speak/like Spanish. Same with MATLAB and Octave.

> Note: Octave can be run in "traditional mode" (by including the --traditional flag when starting Octave) which makes it give an error when certain Octave-only syntax is used.

Solution 2 - Matlab

A more complete link to the list of differences is on the Octave's FAQ. In theory, all code that runs in Matlab should run in Octave and Octave developers treat incompatibility with Matlab as bugs. So the answer to your first question is yes in theory. Of course, all software has bugs, neither Octave or Matlab (yes, Matlab too) are safe from them. You can report them and someone will try to fix them

Octave also has extra features, most of them are extra syntax which in my opinion make the code more readable and more sense, specially if you are used to other programming languages.

But there's more to Octave than just the monetary cost. Octave is free also in the sense of freedom, it's libre, but I don't think this is the place to rant about software freedom.

I do image processing in Octave only and find that the image package suits my needs. I don't know, however, what will be yours. So my answer to if it's worth the cost is no, but certainly others will disagree.

Solution 3 - Matlab

MATLAB is, first and foremost, a commercial offering. Therefore, everything in MATLAB pretty much works out of the box. All the core functionality is solid, and if you're working on a special project then MATLAB probably has an add-on they can sell you that adds a lot of additional domain-specific .m files for you. It isn't cheap, but it works and it will get the job done without complaint.

Octave always shows its open-source, information-wants-to-be-free roots. It's free, and it will remind you that it's free at every opportunity. It's developed by volunteers who hate Windows with a passion. Therefore Octave runs on Windows grudgingly. It's quite surprising that as many MATLAB features exist as they do.

But here's the rub. Anytime you try to do something more than trivially complex, Octave suddenly breaks in subtle and hard-to-understand ways. Oops -- the terminal driver had an overflow somewhere deep in the OpenGL layer. You can't print. Oops -- the figure plots do strange things with their fonts. Good luck figuring out why. Oops -- there's some hidden dependency between Octave and some other obscure bit of free software, so it won't compile. Good luck figuring out which it is.

And the Octave response is hey! It's free software! You have all the source code, and you can fix all those bugs yourself! Maybe if I had infinite time and resources on my hands, I could spend all my time fixing bugs in free software, but I personally don't. If I worked in academia, I might.

So at the core, the issue of whether to choose MATLAB or Octave comes down to one question. Interestingly, that question is always the same, when choosing between commercial vs. free software variants.

And the question is:

Do you have more money than time?

Solution 4 - Matlab

Octave is basically an open source version of MATLAB. It was written to be just that. MATLAB has a very nice GUI which makes it a bit easier to use, but the next stable release of Octave will also have a GUI, which I have tested in the unstable release, and looks fantastic. Octave is much more buggy because it was developed and maintained by a group of volunteers, where the development of MATLAB is funded by millions of dollars by industry. I'm still a student and am using a student version of MATLAB, but I am thinking of going over to Octave once the stable version with the GUI is released.

MATLAB is probably a lot more powerful than Octave, and the algorithms run faster, but for most applications, Octave is more than adequate and is, in my opinion' an amazing tool that is completely free, where Octave is completely free.

I would say use MATLAB while you can use the academic version, but the switch to Octave should be seamless as they use the exact same syntax.

Lastly, there is the issue of Simulink. If you want to do simulation or control system design (there are probably a million other uses), Simulink is fantastic and comes with MATLAB. I don't think any other comes close to this. Although Scilab is apparently a 'good' open source alternative, I haven't tried it.

Solution 5 - Matlab

I just started using Octave. And I have seen people use MATLAB. And one major difference as mentioned above is that Octave has a command line interface and MATLAB has a GUI. According to me having a GUI is very good for debugging.

In Octave you have to execute commands to see what is the length of a matrix is, etc., but in MATLAB it nicely shows everything using a good interface. But Octave is free and good for the basic tasks that I do. If you are sure that you are going to do just basic stuff or you are unsure what you need right now, then go for Octave. You can pay for the MATLAB when you really feel the need.

Solution 6 - Matlab

The thing that makes MATLAB so popular and special is its excellent toolboxes in different disciplines. Since your main goal is to learn MATLAB, so there is not different at all if you work with Octave or MATLAB!

Just going and buying MATLAB without any cool toolbox (which basically depends on your major) is not really a reasonable expense!

You can definitely have a good start with Octave, and follow tons of tutorials on MATLAB on the Internet.

Solution 7 - Matlab

There is not much which I would like to add to Rody Oldenhuis' answer. I usually follow the strategy that all functions which I write should run in Matlab.

Some specific functions I test on both systems, for the following use cases:

a) Octave does not need a license server - e.g. if your institution does not support local licenses. I used it once in a situation where the system I used a script on had no connection to the internet and was going to run for a very long time (in a corner in the lab) and used by many different users. Remark: that is not about the license cost, but about the technical issues related.

b) Octave supports other platforms, for example, the Raspberry Pi (http://wiki.octave.org/Rasperry_Pi) - which may come in handy.

Solution 8 - Matlab

Nested functions and closures are now supported by many languages, including MATLAB. JavaScript promotes closures as a first class design principle.

Sadly, Octave does not support closures (nested functions with lexical scoping).

According Bug: handles to nested functions are not yet supported one might even get the impression that the developers do not want or are unable to get it right. This 2013 bug was fixed in 2020, btw.

This will break a lot of code, both ways. No workaround.

Solution 9 - Matlab

Octave and MATLAB have many similarities. But Octave is a command line interface. You have to type each command in the command prompt, while MATLAB comes with best GUI. I recommend first you use MATLAB student version; after learning basic lessons use GNU Octave permanently.

Now GNU Octave comes with a GUI, but it is a development version now. There are some GUI front end for GNU Octave, like guioctave, xoctave (not free), DomainMath IDE, etc.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlswimView Question on Stackoverflow
Solution 1 - MatlabRody OldenhuisView Answer on Stackoverflow
Solution 2 - MatlabcarandraugView Answer on Stackoverflow
Solution 3 - MatlabjohnwbyrdView Answer on Stackoverflow
Solution 4 - MatlabJonnyView Answer on Stackoverflow
Solution 5 - MatlabsachinrView Answer on Stackoverflow
Solution 6 - MatlabArezaView Answer on Stackoverflow
Solution 7 - MatlabAlexander KempView Answer on Stackoverflow
Solution 8 - MatlabWolfgang KuehnView Answer on Stackoverflow
Solution 9 - Matlabvinu k nView Answer on Stackoverflow