I am a die hard user of matlab, mostly because this is what I learned first and I have not encountered a problem with a significant enough difference to switch. I come from numerical optimization/linear algebra, where I have performed optimization and eigenvalue computations in millions of degrees of freedom. Recently, I have entered the realm of randomness, where I was originally under the impression I would be forced to change. But, after optimizing code, and carefully initializing the seed to the random number generator, I am able to do the same Monte Carlo tasks as my contemporaries in roughly the same time. My understanding has been that base-level 'if' statements, etc., are significantly slower in matlab. However, if there are significant computations within each loop which can be vectorized, I'm not convinced C would be better. And, anyway, matlab seems to do just fine, in the sense that my upper bound is no less than any other professional (and in many cases, seems to be more). I have a feeling that I will get lots of responses from pro-C people here, who have written off matlab long ago as some trivial toy language. I am a professional researcher and contend that matlab is competitive for the highest level computationally intensive mathematical programming. Am I wrong ? Do I need to consider changing to a lower-level language, such as C/FORTRAN ? Why or why not ? Are there others like me ? Thanks alot! Cheers
I work with a team of professional research geophysicists though I'm more of a numerical software engineer myself. I think that if your work is numerical mathematics then Matlab is very suitable, especially so since you are already skilled in its use.
You might write faster programs if you picked up C or Fortran, though perhaps not as much faster as you would hope since Matlab uses, for a lot of its numerical routines, the same BLAS (etc) libraries as you would if you were writing in C or Fortran. But from my working experience my colleagues find the ability to write programs more quickly much more important than writing quicker programs. They generate a lot of ideas which, upon reflection, they later reject. The added speed of development that Matlab gives over and above C and Fortran means that they go through the whole cycle (which generally includes visualisation of results) a lot more quickly and do it more often, so doing more science by some crude measure.
(As an aside: one of the jobs I get is to turn some of the Matlab code that is not rejected into Fortran programs for execution on the company's large clusters. But that's what happens to some of our codes when the initial research is complete and we want to deploy them for production.)
I'd also point out that Matlab has good parallel computing capabilities (if you can afford them) through its Parallel Compute Toolbox, which will probably be of interest as your problems become larger and you realise that you are underusing some of your cores, gosh it's even got integration with GPU computing in the latest release.
In a nutshell I'd suggest that staying with Matlab will allow you to focus on your mathematical research and not divert your attention to wrestling with a new toolset. Especially so since you do not suggest that Matlab is inadequate for your expected needs.
If you are mainly involved in prototyping algorithms that involve simple data structures, matlab is a great choice. The workflow of many academics working in computational fields is: develop a new algorithm, check that it works in matlab, then you write your paper, and you're done. If this is all you wish to do, stick with what you know (matlab).
If you want to do more than that... Well Fortran and C/C++ are not directly comparable to Matlab because there is just no reason to use a compiled language unless performance is critical. Python, on the other hand, has a similar feature set to matlab, in addition to being a free full programming language with a vibrant online community. The downsides to switching to python are surprisingly negligible, and the upsides are huge. I miss some of Matlab's array handling syntax, as Numpy (python's module for array manipulation) has a few quirks, but that's about it. I switched from matlab to Python recently, and I don't plan on going back. Matlab seemed to make me write code in the worst possible way. My python code is much cleaner, more modular, and easier to read. Also, the Sphinx documentation system is terrific.
In short, consider python if:
- You are going to need to maintain a large codebase
- You want to make your project open source and have others contribute
- You want to make your code available to people without a matlab license
- You want to write your own custom data structures other than arrays (trees, graphs, ...)
- You need to implement non-numeric code (search local directories, download from urls, find local files using regular expressions, text processing)
- You want to generate awesome documentation easily and effectively
- You don't want to spend cash on a matlab license
Here's a link arguing for python over matlab for scientific research: http://www.stat.washington.edu/~hoytak/blog/whypython.html
Here's a self indulgent link showing the amazing potential of python Sphinx to auto-generate beautiful online documentation that seamlessly integrates mathematical derivations and actual source code: http://pythonhosted.org/fit_neuron/overview.html
Python seems poised to become THE standard in scientific computing, so it's definitely worth learning.
Speaking as someone who moves between academia and industry in an engineering field, the only reason I don't use Matlab more is because of the cost. If you and all the people you want to give code to have Matlab licenses then there's no reason to switch.
If you find that parts of your code need to be optimised, you can rewrite just those bits in a lower-level language and call them from your Matlab program. Switching languages for performance reasons is a case of premature optimisation, in my opinion. I solve computation-intensive problems in an iterative process:
- Put together a solution in the quickest and most straightforward way first, which in your case means using the language you know best.
- Run it with a limited data set using a profiler and figure out where the bottlenecks are.
- Fix the worst bottleneck, using any of the following methods: a) Change the algorithm, b) optimise using the features of the current development environment, c) rewrite that bit of code in something that executes faster for that particular problem.
- Go back to 2. until your run time/development time equation reaches whatever threshold you're comfortable with (or, if you're a graduate student, until your supervisor shouts at you to STOP FIDDLING WITH THE BLOODY THING AND JUST RUN IT ALREADY).
In other words, don't stress about performance until it becomes a problem, especially if you're writing code for your own use.
Well I'm more a C++/Java programmer than a Matlab one, although I have used Matlab, but I think that for mathematical research, Matlab is rather well suited. Research is something that involves a lot of experimentation, and C++ is a dire language in which to do experimentation. Matlab makes it very easy to test things quickly, find out which ones work and which don't, and move on. You can always code up your solutions in another language once you know what you want to do, assuming that the Matlab version is too slow (from the limited amount I've seen of it, sometimes it is, sometimes it isn't).
Bottom line: you might not want to use Matlab for everything (the phrase "if all you have is a hammer, everything looks like a nail" springs to mind), but it's certainly a good language for the specific task of mathematical research.
I would also consider the software Mathematica which is great for some of the needs mathematicians have
I think matlab is fine for you, because c is a general purpose language, while matlab is designed for math.
Matlab excels in:
- high-level matrix math (just compute A*B, you don't have to call A.multiply(B) or some C++/Java type syntax)
- data analysis
- data visualization
- interfacing with Java
and there are enough libraries/tools to do almost anything else in an easy (but not necessarily optimized) way that you can stay working in MATLAB once you start.
I would hate to use some software package that is great for, say, matrix math, but then when I go to do something else, it is lousy and I face the choice of either accepting that lousiness or abandoning my work and using different software.
You willl certainly see that Matlab is fast on some points, but when you need specialized things like manual memory management for working with a vector that exceeds what Matlab wants to give you, you'll need to jump through some hoops.
I'm sure you can do everything quick and easy in Matlab, but I've come to see it as quite cumbersome in terms of elegance and post-optimization readability. Vector math is certainly fun and quick, but I find it hard to spot the dimensions sometimes.
I'd say stick with what you know, and switch when you're convinced Matlab can't do it. Learning another language is hard, especially when you want quick code, and numerical calculations.
On a sidenote, I prefer C++, together with some awesome libraries (GSL, Eigen, etc.). The funny thing is that I still make my plots in Matlab, because I came to know that part of Matlab very well :)
© 2022 - 2024 — McMap. All rights reserved.