Why do people still pay and use matlab having python numpy and matplotlib?
Mathematica vs MATLAB
Performance Tradeoff - When is MATLAB better/slower than C/C++ - Stack Overflow
numerics - Mathematica vs. MATLAB philosophy - Mathematica Stack Exchange
I’ve played around with MATLAB and it seems simple enough to learn. I had some extra time this semester and wanted to study it more.
I ran into Mathematica while doing some study research on MATLAB. It also sounds like a really cool program to learn.
Does anyone have an opinion on which is better to learn?
I’ve seen MATLAB work really well with Python. Can Mathematica work as well?
I have been using Matlab and C++ for about 10 years. For every numerical algorithms implemented for my research, I always start from prototyping with Matlab and then translate the project to C++ to gain a 10x to 100x (I am not kidding) performance improvement. Of course, I am comparing optimized C++ code to the fully vectorized Matlab code. On average, the improvement is about 50x.
There are lot of subtleties behind both of the two programming languages, and the following are some misunderstandings:
Matlab is a script language but C++ is compiled
Matlab uses JIT compiler to translate your script to machine code, you can improve your speed at most by a factor 1.5 to 2 by using the compiler that Matlab provides.
Matlab code might be able to get fully vectorized but you have to optimize your code by hand in C++
Fully vectorized Matlab code can call libraries written in C++/C/Assembly (for example Intel MKL). But plain C++ code can be reasonably vectorized by modern compilers.
Toolboxes and routines that Matlab provides should be very well tuned and should have reasonable performance
No. Other than linear algebra routines, the performance is generally bad.
The reasons why you can gain 10x~100x performance in C++ comparing to vectorized Matlab code:
Calling external libraries (MKL) in Matlab costs time.
Memory in Matlab is dynamically allocated and freed. For example, small matrices multiplication:
A = B*C + D*E + F*G
requires Matlab to create 2 temporary matrices. And in C++, if you allocate your memory before hand, you create NONE. And now imagine you loop that statement for 1000 times. Another solution in C++ is provided by C++11 Rvalue reference. This is the one of the biggest improvement in C++, now C++ code can be as fast as plain C code.If you want to do parallel processing, Matlab model is multi-process and the C++ way is multi-thread. If you have many small tasks needing to be parallelized, C++ provides linear gain up to many threads but you might have negative performance gain in Matlab.
Vectorization in C++ involves using intrinsics/assembly, and sometimes SIMD vectorization is only possible in C++.
In C++, it is possible for an experienced programmer to completely avoid L2 cache miss and even L1 cache miss, hence pushing CPU to its theoretical throughput limit. Performance of Matlab can lag behind C++ by a factor of 10x due to this reason alone.
In C++, computational intensive instructions sometimes can be grouped according to their latencies (code carefully in assembly or intrinsics) and dependencies (most of time is done automatically by compiler or CPU hardware), such that theoretical IPC (instructions per clock cycle) could be reached and CPU pipelines are filled.
However, development time in C++ is also a factor of 10x comparing to Matlab!
The reasons why you should use Matlab instead of C++:
Data visualization. I think my career can go on without C++ but I won't be able to survive without Matlab just because it can generate beautiful plots!
Low efficiency but mathematically robust build-in routines and toolboxes. Get the correct answer first and then talk about efficiency. People can make subtle mistakes in C++ (for example implicitly convert double to int) and get sort of correct results.
Express your ideas and present your code to your colleagues. Matlab code is much easier to read and much shorter than C++, and Matlab code can be correctly executed without compiler. I just refuse to read other people's C++ code. I don't even use C++ GNU scientific libraries because the code quality is not guaranteed. It is dangerous for a researcher/engineer to use a C++ library as a black box and take the accuracy as granted. Even for commercial C/C++ libraries, I remember Intel compiler had a sign error in its sin() function last year and numerical accuracy problems also occurred in MKL.
Debugging Matlab script with interactive console and workspace is a lot more efficient than C++ debugger. Finding an index calculation bug in Matlab could be done within minutes, but it could take hours in C++ figuring out why the program crashes randomly if boundary check is removed for the sake of speed.
Last but not the least:
Because once Matlab code is vectorized, there is not much left for a programmer to optimize, Matlab code performance is much less sensitive to the quality of the code comparing with C++ code. Therefore it is best to optimize computation algorithms in Matlab, and marginally better algorithms normally have marginally better performance in Matlab. On the other hand, algorithm test in C++ requires decent programmer to write algorithms optimized more or less in the same way, and to make sure the compiler does not optimize the algorithms differently.
My recent experience in C++ and Matlab:
I made several large Matlab data analysis tools in the past year and suffered from the slow speed of Matlab. But I was able to improve my Matlab program speed by 10x through the following techniques:
Run/profile the Matlab script, re-implement critical routines in C/C++ and compile with MEX. Critical routines are mostly likely logically simple but numerically heavy. This improves speed by 5x.
Simplify ".m" files shipped with Matlab tool boxes by commenting all unnecessary safety checks and output parameter computations. Please be reminded that the modified code cannot be distributed with the rest of the user scripts. This improves speed by another 2x (after C/C++ and MEX).
The improved code is ~98% in Matlab and ~2% in C++.
I believe it is possible to improve the speed by another 2x (total 20x) if the entire tool is coded in C++, this is ~100x speed improvement of the computation routines. The hard drive I/O will then dominate the program run time.
Question for Mathworks engineers:
When Matlab code is fully vectorized, one of the performance limiting factor is the matrix indexing operation. For instance, a finite difference operation needs to be performed on Matrix A which has a dimension of 5000x5000:
Use with AIB = A(:,2:end)-A(:,1:end-1)
The matrix indexing operation makes the Matlab code multiple times slower than the C++ code. Can the matrix indexing performance be improved?
In my experience (several years of Computer Vision and image processing in both languages) there is no simple answer to this question, as Matlab performance depends strongly (and much more than C++ performance) on your coding style.
Generally, Matlab wraps the classic C++ / Fortran based linear algebra libraries. So anything like x = A\b is going to be very fast. Also, Matlab does a good job in choosing the most efficient solver for these types of problems, so for x = A\b Matlab will look at the size of your matrices and chose the appropriate low-level routines.
Matlab also shines in data manipulation of large matrices if you "vectorize" your code, i.e. if you avoid for loops and use index arrays or boolean arrays to access your data. This stuff is highly optimised.
For other routines, some are written in Matlab code, while others point to a C/C++ implementation (e.g. the Delaunay stuff). You can check this yourself by typing edit some_routine.m. This opens the code and you see whether it is all Matlab or just a wrapper for something compiled.
Matlab, I think, is primarily for comfort - but comfort translates to coding time and ultimately money which is why Matlab is used in the industry. Also, it is easy to learn for engineers from other fields than computer science, with little training in programming.
I have abused Mathematica since version 3 and right out of the gate I will say that the Notebook interface remains unparalleled compared to other platforms: MATHLAB, Python, R, Stata (of which I have working experience). Although Livescripts have been a welcome addition to MATLAB, I still prefer Mathematica as a comfortable graphical interactive workspace. I have only used MATLAB for the past 3 years, so my experience is limited. I find working with matrices cleaner in MATLAB and the documentation/implementation of higher-level matrix functions more informative (and easier to relate to textbook instruction of Linear Algebra). (I have, respectively, a love-hate relationship with MATLAB and Mathematica when it comes to pre-multiplying a matrix by a column vector.)
In data analysis: I like Mathematica’s handling of statistical distributions, but I find its statistical modelling limited and awkward to extend beyond Master’s level applied statistics. MATLAB is has a much richer implementation and output. Mathematica’s Bayesian capabilities (including various MCMC offerings) are no where to be found. (I recognize this last statement is not literally true; but it may as well be because efforts to create Bayesian models for undergraduate-level applications requires considerable competence (as indicated by the coding examples offered by Community contributions). MATLAB has more extensive statistical modelling offerings but likewise gets complicated, but possible, to use for Bayesian stats. I find Mathematica’s handling of temporal data (and date/time functions) and time series analysis superior to MATLAB. And when it comes to data munging, I also prefer Mathematica (due largely to the ease of intermediate display of data in the Notebook). I do not have experience in MATLAB with stochastic processes; but the Mathematica implementation is very impressive and enjoyable to use.
I prefer to work with text data and strings in Mathematica and my limited experience with MATLAB suggests that Mathematic’s string manipulation capability is superior.
Neural networks: At the moment, my knowledge of the Machine Learning implementations in both environments is limited; but I prefer MATLAB and my early experience suggests autodidactic ingestion of Deep Learning and Neural Nets is more approachable and rewarding in MATLAB. The Deep Network Designer in MATLAB is a superior environment for building and experimenting with NN. I have no direct comparison, but I find MATLAB faster, especially with the Parallel Computing Toolbox.
I find MATLAB’s Regression and Classification Learner “apps” superior and much faster (especially Gaussian Process modelling) to Mathematica’s Predict and Classify. However, if I supplement the latter with the Find… family of commands; I think I would lean to Mathematica. The issue here is more my knowledge as a User (ease of use and immediate functionality often become less attractive as the user’s capability and the problems’ complexity increases; and I am at the lower end of the scale on both of these considerations).
I have not used MATLAB long enough to have an opinion on its evolution. But Mathematica has gone through significant changes. I had the impression that Stephen Wolfram took his eyes off the ball between, say v8 and v10, but has returned to press for a strategic and consistent language-level implementation. The vision of this endeavor is breath-taking. For example, the Entity Framework design is awesome, if awkward. And more generally, I find the improvements are impressive but sometimes difficult to grok and work with without a lot of fine tuning. As well, it seems some of the implementations run out of gas before they get to a full maturity (where they are worth the time and effort to learn in detail and by rote). I would suggest Wolfram’s database access and instantiation in Mathematica’s knowledge representation and access framework as an example of the latter. In my experience Mathematica’s database access is superior to MATHLAB. The impressive RelationalDatabase, EntityStore, EntityValue, EntityClass, and family of …EntityClass commands are so full of promise. But, for me, they wander into a jungle of syntax that is so difficult to get right that I fall back to what I did five versions ago with SQLExecute. (My bad, I just found the “Relational Databases Quick Start “ Technote which is “New in 12.0”. But I think this underlines my point. I had given up trying to master the Entity Framework and SQL because the implementation and documentation were incomplete in V11. And, I will get back to you when I finish what looks like the longest Technote in Mathematica. But I will not mind if the implementation does meet the promise and my expectation). (By the way, I feel this is similar to @Szabolcs point: “too many operators and the need to remember their precedence never bothered me, but I agree that one must have discipline and exercise self-restraint when using operator forms. I think I use them less, and them more and more restrictively, as time passes, not more.”
I will not address the Symbolic capability here. I have made primitive use of MATLAB’s Symbolic Math and Partial Differential Equation Toolbox but I would NOT give them a moment’s thought if I wanted to produce something akin to Nachbar’s “Epidemiological Models for Influenza and COVID-19” Notebook (https://www.wolframcloud.com/obj/rnachbar/Published/Epidemiological%20Models%20for%20Influenza%20and%20COVID-19--full%20version.nb).
Both platforms are now so rich, extensive, and complicated that they require a support Community and third-party publications. In terms of texts: I find MATLAB has out paced Mathematica and that it is easier to find reference works for MATLAB. As to community support, I find Mathematica Stack Exchange particularly good. But, in my experience MATLAB’s Community support and offerings is more active and richer than Mathematica’s.
As to the Philosophy, I think, with Stephen Wolfram actively at the head and pushing his Company towards a strategic goal with adequate and consistent documentation, Mathematica holds a clear edge in vision and thematic endeavor. And it does feel like a Computational Engine with scary, almost unmanageable power. Something well-placed in a Consulting firm versus a manufacturing plant. MATLAB, on the other hand feels like a comfortable enterprise engineering application platform, squarer and more manageable.
I work with Mathematica everyday (as a hobbyist) but I enjoy some autodidactic exploration with MATLAB. I would accept either as my working environment in whatever Company I worked for; but when I got home at night I would prefer a fight with Mathematica’s syntax (and the eventual reward) than a dry serving of MATLAB.
Well, here's my reply to a similar question from a while back:
I'm looking for comprehensive and rather long answers to these questions.
- What's the difference between Mathematica and MATLAB?
Several letters in the names.
- Can MATLAB do what Mathematica does and vise versa?
Yes. Both are Turing complete. Good luck writing heavy symbolic work in MATLAB though.
- What are the pros and cons of each of them?
Many pros here at this site, a few users have done prison time. No idea re: Matlab expertise or criminality.
- Who are the appropriate users of each tool?
Ones that make up their own mind based on experience with the two vs taking polls.
- Will it benefit someone if he knows both of them?
Sure, they can answer comparison questions.
- What are the capabilities of Mathematica that makes it unique?
Stephen Wolfram. 'nuf said. And if you disagree, he'll send a pack of wild cellular automata your way to... "evolve" your opinion.
- Can Mathematica play the role of an easy to use advanced scientific calculator for an engineer who is most of the time dealing with multi-variable calculus and partial differential (electromagnetism) equations?
Yes.
In all seriousness, I use (daily) Mathematica and MATLAB, and weekly Maple, NumPy, SageMath, and PARI/GP.
They are all capable of doing what the others do, with varying degrees of effort and/or self-flagellation depending on the task at hand.
I think a large part of the tribalism re: Mathematica/MATLAB is simply a case of knowledge passing - the engineering professor was taught and used MATLAB, so torpedoes be damned, that's what they'll mandate. It kind of makes sense - the tool does what they need, and there isn't any need to fix it if it's not broken.
For much of what I do, the symbolic capabilities of Mathematica along with its comprehensive probability capabilities make my tasks much, much easier than trying to do the same in the other tools.
If I were forced to pick one and only one of my tools in the mathematical toolbox, it would be Mathematica, simply because I can do in it anything my other tools can do, and I can easily do in it things the other tools are either intrinsically incapable of doing and/or require me to write my own symbolic CAS.
On my deserted island, Mathematica is my Wilson...

Regardless of what completes the phrase "Python vs ...", the answer is always going to be Python.
Very few people who are serious about using optimisation in production use MATLAB, and the ones who do can't wait to move away from it.
As to why, there are plenty of reasons. MATLAB is:
licensed
closed source
not object-oriented friendly, so it's a very bad choice for complex software
hard to distribute computations, and has a very expensive license for doing so
very hard to interface with
not scalable
nigh-impossible to hire professional programmers for
Seriously, if you want to be able to use your own code after your PhD, don't use commercial packages.
From a programming perspective, I have personal experience in the bottlenecks. I wrote the very first version of my solver in MATLAB, and I could solve problems of ~5 variables in reasonable time. Moving to C++ increased that to 200 variables. Rewriting the solver in C++ once I had experience increased that to 100,000 variables, and hiring professional developers increased that to >1,000,000 variables.
What's interesting here is that with the experience I have now, 10 years later, I know there's no way I could have ever scaled our software beyond 100 variables in MATLAB, but I could have in Python.
I agree with everything Nikos said and I add some colors to some of the reasons:
- Python is free and open-source but Matlab is not. Anyone can write codes in Python and share it with others who can easily run that code (as it's free software) but your Matlab codes can be run only by those who have a license.
- Just because Python is open-source and free, it means it's widely available to a larger audience. And when you're talking about projects in industry, spending money on a piece of software, IMO, is not justifiable when there is a widely accessible alternative.
- It makes more sense not to tie a piece of code to a person. Since there are more and more Python users, almost anyone can read and modify your Python code in a company, but if you leave a place and there are not many proficient in Matlab, that's a big loss for the company. It can be easily avoided by using general-purpose programming languages such as Python.
- Remember that the work in the industry is not just focused on matrix and vector operations. So, my suggestion: gradually start getting out of Matlab comfort zone.
I think the most important thing to consider is the task the entrant will actually have to tackle and how it fits with the actual design purpose of the languages. By design purpose I mean the task the language was made to solve. It is often also the task the languag is best at.
If the task would be doing statistical analysis and making statistical graphics then R is best out of the box. R was built specifically for statistical analysis and it is very good at it.
When you would be doing various things like machine learning, statistics, numerical modeling all at the same time then Python would be most suitable as it is a sort of "swiss army knife" language. The design purpose of Python was to be easy to learn and easy to read general purpose language ie with no particular single purpose in mind. You can do statistical analysis in Python but it is not as nice as in R. You can do numerical modeling in Python but it is not as comfortable as MATLAB.
The initial design purpose of MATLAB is in its name "MAtrix LABoratory" and therefore it was made with the aim of numerical modeling in mind.
Also important to consider is the languages used within a research group the entrent will join. If there already exists a good library written in MATLAB then you should learn MATLAB.
I agree with David, there has always been a split between people on the conservation/ecology side of bioacoustics and those on the engineering/computer science side of things (the same trend holds true across conservation tech from my experience). It's basically down to undergrad/grad curriculum - any biostats class you take, at least in American universities, is guaranteed to be in R. Python was what the coding/programming students took, and when you are young still trying to figure things out it doesn't feel intuitive to take something that seems so distant from your area, despite the fact it does/will. One of my big regrets from undergrad/grad school is not taking Python courses.
So just from this, what people find "easy" and "intuitive" depends on their training, the research lab they were in/people they were surrounded by, etc. The reason I started to (still in the process...) learn Python was because I need to run ML models and if you're doing ML, especially deep learning, Python is the gold standard and R does not really have an environment for that (I think 'medium' is generous in your table, personally). But for the ecological modelling, R is great. I agree with the previous comments from Mirko that it depends on the use case you have and what specific functionality is required for that goal.
I support writing "Matlab", with just one capital letter. This is the normal English capitalization rule. Abusing capitalization and special characters for emphasis is just a commercial trick, but I don't think it has any advantage when it comes to legibility.
See this Washington Post copy editor's take on the topic.
- Everything you need to know about capitalization you learned in kindergarten.
Well, that might be an exaggeration, but the point is that the most basic of capitalization rules are not to be trifled with. Proper nouns are capitalized. All caps is for initial-based abbreviations. [...]
- Funky logos are nothing new.
In the old days, battles on this front usually involved companies that insisted on being identified in all caps. The uppercase treatment, after all, makes something STAND OUT. But there weren't as many battles as there are today, because copy editors and even writers knew that logos are logos and English is English. "You want all caps?" an ink-stained wretch with a green eyeshade might have asked. "Go buy an ad!"
As it's a registered trademark of the Mathworks, I'd go with their capitalization: MATLAB.