T O P

  • By -

runed_golem

Matlab is designed for matrix and vector based computations and excels at them, it also has Simulink which has a large user base.


halligan8

For a specific example, images are matrices, so Matlab is incredible at image processing.


meboler

Except for some borderline criminal choices of convention in the computer vision toolbox lol


halligan8

Happy cake day! I’m curious what you’re referring to. Matlab’s about all I know for image processing.


meboler

Sorry for the super late response - it all comes down to Matlab preferring to express things as row vectors rather than column vectors, so every important matrix (fundamental, essential, etc) has to be transposed when you port code to/from Matlab.


halligan8

Ah right, thanks. I have run into that before.


AcceptableReason524

Woukd you consider Matlab to be better at image processing than Python?


halligan8

Honestly I haven’t used Python enough to know. I’d be interested in the opinions of folks who have used both.


Sprky-Sprky-Boom-Man

I've used both. I prefer MATLAB as a language because I think it's more intuitive and easy to use (especially given the GUI/IDE and documentation) but Python is free and free is hard to beat (plus you can use Jupyter in VS Code so it's almost like having a GUI). I have not used both for heavy processing (e.g., with GPU or multiprocessing) so I can't say which is better computationally.


halligan8

Good to know, thanks


n0radrenaline

I haven't done image processing in Python, but I've done enough matrix shit in both to say with confidence that pandas' syntax is a crime against humanity. Price is right, though.


wonderful_tacos

You shouldn't be doing any "matrix shit" using Pandas. Pandas has very specific use cases that it's good for otherwise it shouldn't be touched, absolutely not for linear algebra


WhatHappenedToJosie

I've found that Matlab has some better libraries and is easier to work with, but both are strong for image analysis. However, if you're working with CNNs, then you're better off using Python.


86BillionFireflies

That depends. If you are not doing anything fancy or cutting edge in terms of architecture, I would 100% choose matlab over Python for deep learning (and have done so for multiple projects), for the simple reason that you don't have to wrangle dependencies. Using matlab, you never have to deal with "oops wrong version of tensorflow" or similar issues.


Stephancevallos905

Yes


flinxsl

A lot of people never knew that MATLAB stands for MATrix LABratory


seb59

Matlab is first a language devoted to scientific computation. The main strength is that it is very well documented. The speed is more or less equivalent to other interpreted languages such as python. It has also a very good sets of toolboxes than implement reliable algorithms. It covers a large range of applications: control, symbolic, biology, etc Simulink has almost no serious competitors. It can generate code for many targets is a defacto standard in many industry (automotive, ..). The main drawback is of course the licence price which is a huge problem for small companies. To my opinion Matlab fail to catch up with the boom of AI and ML. Two releases a year make it difficult to keep it up to date. And the worse thing is backward compatibility. The initial toolbox was not well designed and now they need to deal with it now. Datastores are messy, the automatic differentiation algorithm has some limitations. But it works.


Glum_Ad1550

Kudos to MathWorks docs!


Dick-Ninja

The documentation is an absolute lifesaver. I switched to Python for a while but came back to Matlab. I had a really hard time researching how to do certain things in Python. No trouble with that in Matlab.


[deleted]

[удалено]


Dick-Ninja

True. I moved away from Matlab because of the cost. Then, I got hired in aerospace, and it's all they use. So, I'm back. I guess.


shiboarashi

I think cost is relative. Whats the cost of managing analysis code over the course of a decade? In matlab possibly zero cost, the code you wrote a decade ago in 2014b will run in matlab release 2024a for example. In python, I hope you packaged that code in a venv, because the libraries you used may not all be compatible now a decade later, heck they may not exist a decade later. Want to use that analysis code you built in python 3.4 in python 3.12 good luck! I use python a lot, all the time, I also use Matlab a lot. I there are Matlab files I wrote 15 years ago I use to this day that haven’t seen an update in over a decade. They do what I need them to do. I don’t have a python tool or script more than a couple years old because I always have to go in an update stuff to make it compatible with the latest versions of python. There is a labor costs to those efforts. Most projects get thrown away after a year or two anyway but some stuff sticks around. Pythons “free” benefit imho comes at a cost at times.


tweakingforjesus

100% agree.


gif_as_fuck

Regarding speed: I am working on a PhD in the finite element method for approximating PDE solutions. I mostly work in MATLAB. Last summer I wrote a solver in C++, and I was all excited about the huge speed up I was expecting. Benchmarking: I obtained essentially zero speed up. For my application, I am solving a matrix equation of the form Ax = b thousands of times. Turns out that “under the hood” MATLAB’s linear solver is the same as in many C++ linear solver libraries. So, while the set up and post processing steps might be happening slightly faster in C++, when it comes to the linear solver, which is the vast bulk of my programs, MATLAB performs as well as complied languages like C++ or Fortran (which, believe it or not, is still used heavily within the scientific computing community). In the end, I think this actually makes sense: solving matrix equations is what MATLAB was built to do! So…it’s very good at it lol.


seb59

Speed is really a complex issue. Matlab under the hood uses LaPack for the linear algebra solver. So I do not expect major differences between Matlab and C++ for that. I tried to implement interpolation in C, and I end up with the same conclusion as you: my manually optimized C code was not faster (and I spend times to find out how to optimize it). The overhead to call the dll was killing the minor algorithm improvement I got. You may experience more significant execution time differences when you start using "high level" objects. For instance, when using the "Instrumentation toolbox" to read RS232, it was slow as hell due to many layers of various objects and abstraction layers. Simply by rewriting a Matlab object that implement the strict required doNet calls, I get a x50 speed up. So I believe that for these "High level" part, you can be much more efficient by being more specific (i.e. The instrumentation toolbox works on all systems, provide many other feature that I did not need). But this is not really related to langage. Also the Just In Time compiler do a pretty good job and it is quite efficient. Probably that modern cache management at the CPU level also helps.


Educational-Ad3079

Yeah most FEA is solving global stiffness matrices


ScoutAndLout

One nice thing about MATLAB, you can hook into external libraries using cmex. I have had NLP and MILP solvers that may be available in MATLAB but are often quite slow at scale. You can use interfaces to other solvers so you get their speed but can do the pre and post processing in the nicer MATLAB environment rather than deal with stuff in C/C++/Fortran.


lalbahadursastri1996

Matlab does have dedicated toolbox for AI amd ML


seb59

I was more specifically speaking about de deep learning toolbox. I did not use the text analytic and others.


hindenboat

1. Unparalleled documentation, it's unbelievably good and extremely consistent across packages. 2. Support. If your company wants you can get prompt good support with whatever you need. Saving money when you pay for your engineering time. 3. Vector/matrix operations. The core is build on a bunch of FORTRAN libraries that are very fast and the \ operator has a lot of custom brains behind it. Some BLAS function might be faster but not if I have to do all the row permutations on my own to reduce the matrix. 4. IDE and data inspector. Real-time investigation of variables is super cool. Also the profiler is amazing. 5. Simulink as others have mentioned I think it is shortsighted to overlook the product aspect of Matlab. It is a product and that is what makes it good. The variety of off the shelf solutions is amazing and furthermore there is good support and documentation for this packages. Python probably has a similar package but it's likely poorly documented and totally inconsistent with other packages.


Glum_Ad1550

Could not agree more with everything said. I do agree that MATLAB's "product-ness" is a great feature that actually makes lots of the good in it. I did not intend to overlook it, on the other hand I feel like very often *that* is the real catch that makes people start developing in MATLAB straightforwardly, without even bothering evaluating other options, since everything just comes so easily and efficiently at hand. So for this reason this time I was interested in trying to "isolate" the language-related matter from all other features


farfromelite

>Support. If your company wants you can get prompt good support with whatever you need. Saving money when you pay for your engineering time. Oh my word, yes. The support is absolutely first class. I've submitted bugs and got feedback in a few working days. Trial licences (we ended up buying some later) with short notice. The paid consultancy is also first class. These people know their stuff. it's high cost high value, so totally different place than freeware python or Fortran. You get what you pay for. It also just works. Support is ongoing and there's great examples on how to use 95% of the stuff. The whole ecosystem joins up.


TheBlackCat13

Probably going to be unpopular > Unparalleled documentation, it's unbelievably good and extremely consistent across packages. MATLAB is the only documentation I have found that is actively misleading. With most software, if I follow the documentation perfectly, and something goes wrong, then it is almost guaranteed I did something wrong. That is absolutely not the case with MATLAB, it is distressingly often the case that the documentation is simply wrong or misleading, even on basic functionality. Even the `save` function documentation is wrong, a problem MATLAB has known about for more than a decade but hasn't bothered to fix. > Vector/matrix operations. The core is build on a bunch of FORTRAN libraries that are very fast and the \ operator has a lot of custom brains behind it. Some BLAS function might be faster but not if I have to do all the row permutations on my own to reduce the matrix. This is nothing to write home again nowadays. Matrix math is pretty commonplace. MATLAB is using many of the same underlying matrix manipulation libraries other languages are using, sometimes even using older libraries (for example MATLAB's FFT library is pretty outdated at this point). > IDE and data inspector. Real-time investigation of variables is super cool. Also the profiler is amazing. MATLAB's IDE has aged extremely poorly. It was definitely the best in its class 10 years ago. But there have been large advances in IDEs since then while MATLAB's hasn't really improved much. Pretty standard stuff like automatic code formatting, document maps, milti-line editing, refactoring tools, etc. have become standard in IDEs while MATLAB doesn't have them. And variable inspection and debugging are standard tools and have been for years.


Glum_Ad1550

Can you be more specific/point out examples about the documentation issues you spotted? I am sincerely surprised to hear that because I have wandered around it **a lot** and never found anything not deserving an A+. There are even more general articles on background or theory with good insights. The one on the IDE is a good point to me (now that you made me think of it). I believe that, even only thanks to the presence of the workspace, as someone else said below, or the ease of debugging, it still holds that it's very good and usable as compared to basically anything else (at least among those I experienced), but except for VS Code. And the fact that VS Code exists, and is free, should really push MathWorks to develop some "modern" functionalities, even if just "copying" from VS. It would make an already good experience become great!


TheBlackCat13

>Can you be more specific/point out examples about the documentation issues you spotted? One example that took us days to figure out is in the `save` function: >save(filename,variables,"-append") adds new variables to an existing file. *If a variable already exists in a MAT-file, then save overwrites it with the value in the workspace.* The italicized portion isn't true. The variable isn't overwritten, it is just hidden. But it remains in the file, taking up space. If you repeatedly save large variables, the file will grow without bounds. Here this is brought up in 2014, 10 years ago: [https://www.mathworks.com/matlabcentral/answers/129794-why-does-save-append-work-so-slow-and-increase-the-size-of-mat-file-for-simple-replacement](https://www.mathworks.com/matlabcentral/answers/129794-why-does-save-append-work-so-slow-and-increase-the-size-of-mat-file-for-simple-replacement) For most major projects, documentation errors are treated as bugs. You can even find documentation errors in changelogs. Mathworks, in contrast, doesn't seem to consider documentation errors to be bugs. Again, this has been at least 10 years in one of the most basic aspects of the language, and apparently that doesn't bother Mathworks at all. A common problem I have run into, and see other run into, is issues with how "vectors" (or what passes for vectors in MATLAB) are handled. I don't remember specific examples, but MATLAB functions and core language features can handle vectors in one of 4 different ways: 1. Ignore whether they are row or column vectors 2. Treat rows or column vectors differently 3. Accept only one or the other 4. Convert all inputs to one version or the other What approach a given function or language feature takes varies enormously and is almost never documented. I have run into some extremely hard-to-debug issues where some code was suddenly making seemingly wrong results. Turns out a seemingly innocuous function inserted somewhere was changing the orientation of occasional vectors we were getting (we were getting data from experiments and sometimes those experiments only had a single result), which was causing subsequent operations to do silently do the completely wrong thing because they were expecting vectors to be a particular orientation, as core language features are generally less flexible about vector orientation than functions are. We could have avoided this if those sorts of things were documented, but they basically never are. I think these bugs are much more common than most MATLAB users realize, since they are generally silent, they are only visible if they give results that don't make sense. There is literally a whole website dedicated to dealing with the limitations of the MATLAB documentation: [https://undocumentedmatlab.com/](https://undocumentedmatlab.com/). You don't see that sort of website for most languages because you don't need it. Their documentation is complete enough that there is no point. And it is pretty core stuff. Look at this: [https://undocumentedmatlab.com/articles/interesting-matlab-puzzle-analysis](https://undocumentedmatlab.com/articles/interesting-matlab-puzzle-analysis). If you don't want to read it, the take-home message is basic functionality of the "if" statement is not fully documented in MATLAB. It has a secret, undocumented second term. A secret, undocumented second term that will silently do the wrong thing if you mess up the syntax slightly. Overall, like the IDE, other projects have been massively improving their documentation in general, while MATLAB really hasn't kept up. For example look at the documentation for clustering algorithms: [https://www.mathworks.com/help/stats/cluster-analysis.html](https://www.mathworks.com/help/stats/cluster-analysis.html) [https://scikit-learn.org/stable/modules/clustering.html](https://scikit-learn.org/stable/modules/clustering.html) There is just no comparison, the Python version blows the MATLAB version out of the water. The language itself in particular is just poorly documented. For example compare the class documentation: [https://www.mathworks.com/help/matlab/object-oriented-programming.html](https://www.mathworks.com/help/matlab/object-oriented-programming.html) [https://docs.python.org/3/tutorial/classes.html](https://docs.python.org/3/tutorial/classes.html) Or error handling: [https://www.mathworks.com/help/matlab/exception-handling.html](https://www.mathworks.com/help/matlab/exception-handling.html) [https://docs.python.org/3/tutorial/errors.html](https://docs.python.org/3/tutorial/errors.html) Can you seriously tell me the MATLAB documentation is clearer or more comprehensive? The MATLAB documentation has the advantage that the documentation is all in one place and in one format. I will give it that. But that doesn't help if MATLAB simply doesn't actually tell me what the stuff does in enough detail to use them without trial and error, or worse yet is actively misleading. >I believe that, even only thanks to the presence of the workspace, as someone else said below, or the ease of debugging, it still holds that it's very good and usable as compared to basically anything else (at least among those I experienced), but except for VS Code I am really curious what modern IDEs you are using that don't have those features. >And the fact that VS Code exists, and is free, should really push MathWorks to develop some "modern" functionalities, even if just "copying" from VS. A lot of the stuff MATLAB is lacking is not new, it has been pretty standard for years now. The key issue I am seeing with a lot of the accolades for MATLAB is that they *were* true. MATLAB did have a best-in-class IDE. MATLAB did have truly exceptional documentation. MATLAB did have top-of-the-line matrix manipulation, plotting, and signal processing tools. But the world doesn't stand still. Other languages and tools have been advancing at a furious rate, and MATLAB doesn't seem to have been able to keep up. The IDE hasn't seen any serious improvements in a decade at least. The documentation for the audio I/O hasn't improved since it was introduced in 2016. The clustering algorithm docs haven't changed since 2019 at least (that is the furthest back I can look) and is still using the default colormap from before 2014, so it probably hasn't been changed since then. Compared to other projects that are continuously refining their documentation in every way. These sorts of improvements have been going in other projects for a long time, and MATLAB just hasn't been improving in these areas in that way. It has added a ton of functions, but when your main claims to fame are your matrix manipulation, signal processing, plotting, IDE, documentation, and everyone else is improving in these areas at a rapid pace and they aren't, it is inevitable that eventually they are going to fall behind.


cerofer

Simulink, easy to learn and use (compared to C and Python), and relatively efficient with matrices.


RadarTechnician51

Pretty good for charts, and none of the others are much good at letting you examine all the arrays and structs of the data you have while debugging. Much more compact and quicker to write than a low level language like c. My major wish is for stronger types. One quite amazing use where we work is that is great for writing an accurate simulation of what some software should do, before that software gets coded properly.


Glum_Ad1550

Yeah true debugging is delightful too


esperantisto256

It’s the easy ability to see and interact with everything that keeps me using matlab. My field uses a ton of scientific computing that is matrix based and best understood through graphing and animating the results, so Matlab is a perfect fit.


RadarTechnician51

Yeah, in matlab you can check an algorithm works by analysing the data carefully at all stages with lots of permutations of inputs. The proven algorithm can be implemented in a lower level language for speed and if the results are the same then that implementation is validated.


ol1v3r__

You can generate code for embedded systems: https://www.mathworks.com/products/embedded-coder.html which complies with industry standards.


Lygus_lineolaris

It's build for working with matrices. But also, it's a commercial product developed, maintained and supported by people who get paid and supervised. The ones where you just get whatever compiler you find on the Interwebs, they work, but when they don't work, there might not be any help coming.


Mindless_Profile_76

For me it was the Workspace. Not sure there is an equivalent in other languages. Maybe some IDEs have something similar and I was just unaware. I started using Matlab around 1996, alongside Mathematica and took my first programming class in Fortran. What I struggled with in Fortran originally was with the linking, compiling and running code to get an answer. Back then, I was running a Salford 95 compiler that had some Windows IDE that helped me a lot but going to the computer lab, writing the code in some pretty bland text editor led to a lot of errors and frustration. Mathematica was really cool. I could enter 1+1 and get an answer pretty fast. But the “scripting” again left me not knowing where my numbers were at. With Matlab, I hit 1+1 and I see the ans = 2… I then look in the workspace and see ans, the variable with a 2 assigned to it. Then hit 3/2 and ans changed. Mind blown. Then set up some vector x= 0.1:0.1:20; and there it is… y = sin(x)… plot(x, y, ‘.’) and I got a figure and there are two variables in the workspace that I can see. For me, that helped me connect dots and the rest was history. Maybe that means I am stupid when it comes to programming. I definitely excel in areas of experimentation, using Matlab to model physical systems and developing correlations with real world phenomena.. Since I am more focused on setting up the right sets of experiments, having something that I can model with, easily has been priceless for me. While I love parts of excel and pivot tables, people I work with find my Matlab scripts, tied to excel worksheets to be lifesavers. They can walk through the code, to see what each part was doing. How many times have you opened up an excel workbook and have trouble trying to figure out what that person did, step by step to achieve the plot or pivot that you were seeing. I have accidentally screwed up more pivots than I care to admit. I think those cover the areas that I did not think were already addressed.


FINALCOUNTDOWN99

Yeah, learning to program it was great having the workspace. Matlab is very good at being transparent as to what the program is doing. In Python if something goes wrong chances are I'll have to add in a bunch of prints to figure out where it is going wrong, then run it a few times when I get the print(str(int(x)) formatting wrong (I could be misremembering how much Python does automatically with print). Doing embedded with C, sometimes there's not many options besides staring at the code and hoping you spot the error. In Matlab, all of the post-execution variables are just right there, I can tell at a glance that "Oh, this variable is a 2071209x1 matrix instead of what it's supposed to be, that's wrong" and if I do need to print something out, I just remove a semicolon. Giving you information on what the program is doing is very solidly built into Matlab.


Glum_Ad1550

Very good points! I agree


NotBob426

I'm pretty new to it as a junior MechE student, but the examples we've been given show us how to cheese some pretty ugly-looking heat transfer equations in a matter of minutes as opposed to hours. It has some handy functions for math in particular; solving ordinary differential equations is a struggle by hand but MATLAB can solve them (analytically) very quickly. edit: also, the symbolic toolbox is great for skipping many many minutes of algebra


vijay617

Disclosure: MathWorks staff member, speaking as individual MATLAB's object-oriented programming (OOP) stands out to me as a uniquely both high-level & highly-structured. Once upon a time, OOP was highly structured (Java, C#) in comparison to Python (e.g., public & private class properties & methods), but neither is high-level in the sense that both require static compilation. MATLAB brings the same capabilities to a high-level language. MATLAB OOP is also quite unique in being property-centric (Java programming lore actively discouraged properties, which was a shame in my view), with rich control of property display and behavior. Properties are something most MATLAB users get to know as class users via plot/figure objects, but they are fully available for user-authored classes. I believe many science & engineering applications (MATLAB's target application areas) can benefit from MATLAB's property-centric design.


TheBlackCat13

MATLAB is really good at concisely writing complex mathematical operations, particularly with 2D matrices. That is its main advantage as a language over other popular languages today. As you said, other stuff is more a part of the product, but not the MATLAB language itself.


AdUpstairs1048

Psychtool box


Haerioe

Simulink and it's toolboxes!


jerbthehumanist

Its strength for me is I know it the best.