If you are not yet a user of Python, and its move to become the most common programming language has piqued your interest, the Enthought training team has updated its popular reference guide, ‘Transitioning from MATLAB® to Python’. The guide highlights some of the most important differences between the two languages, including:
- The fundamental data types
- How code is organized in packages
- An overview of the syntax differences
- How indexing and slicing work
- NumPy arrays compared to MATLAB matrices
- How Python mainly uses an object-oriented programming paradigm.
In addition, the guide explores common tasks when doing data analysis or running simulations, with a focus on the most common packages used for each task, such as loading data, cleaning and reformatting data, performing analysis or simulation, plotting, and saving data.
Finally, it introduces two strategies to transition gradually to Python. Both rely on testing to validate that the new Python code works the same way as your MATLAB® code. The problem is approached in 2 ways; by either converting all functions directly to Python or by calling Python from MATLAB®.
Why transition from MATLAB® to Python?
If you’re unsure of whether you’d like to transition to Python, we’ve collected some of the most commonly cited reasons for the change. Cost is often the first reason given, as licensing fees add up quickly and may account for a significant part of a small organization’s budget. Python has the appeal of being free, because you do not have to pay a license fee and you have access to many free open source packages.
Choosing Python – or any other open source language – lets you run your code without being locked-in with a given provider. There is no need to pay a license fee in order to keep your software running. More importantly, it means that colleagues, and others, can run Python code without requiring a license. This can greatly improve the chances of survival for your project.
Finally, Python has the benefit of being a general purpose programming language. Though it is an excellent language for scientific computing, it is not solely a scientific computing language. It can be used to do everything from building a file synchronization system, a photo-sharing service, a 3D modeling and video-editing application, and a video hosting platform, to discovering gravitational waves.
The consequence of such varied uses is that you can find tools to do almost all common tasks. This allows you to use Python for your entire application, from hardware control and number crunching, to web API and desktop application. And for cases when a feature or a library exists only in another language, Python can easily interface with C/C++ and Fortran libraries. There are also Python implementations for some of the major other languages, such as IronPython for C, and Jython for Java.
Build your Python skills
Enthought offers a number of Python training courses for those looking to improve their skills. If you are currently a MATLAB user, we recommend Enthought’s Python for Scientists and Engineers as the perfect entry point into the scientific Python world. Sign up for a training session through our website, or contact us to learn more about our on-site corporate programs.
About the Author
Alexandre Chabot-Leclerc, Ph.D., Director, Training Solutions holds a Ph.D. in electrical engineering and a M.Sc. in acoustics engineering from the Technical University of Denmark and a B.Eng. in electrical engineering from the Université de Sherbrooke.