Transitioning from MATLAB to Python

Author: Alexandre Chabot-Leclerc, Ph.D., Director, Training Solutions

Download the guide here.

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®

Download the guide here.

Watch the webinar on migrating from MATLAB to Python here.

MATLAB to Python

 

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.

Download the guide here.

 

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.

Share this article:

Related Content

Leveraging AI for More Efficient Research in BioPharma

In the rapidly-evolving landscape of drug discovery and development, traditional approaches to R&D in biopharma are no longer sufficient. Artificial intelligence (AI) continues to be a...

Read More

Utilizing LLMs Today in Industrial Materials and Chemical R&D

Leveraging large language models (LLMs) in materials science and chemical R&D isn't just a speculative venture for some AI future. There are two primary use...

Read More

Top 10 AI Concepts Every Scientific R&D Leader Should Know

R&D leaders and scientists need a working understanding of key AI concepts so they can more effectively develop future-forward data strategies and lead the charge...

Read More

Why A Data Fabric is Essential for Modern R&D

Scattered and siloed data is one of the top challenges slowing down scientific discovery and innovation today. What every R&D organization needs is a data...

Read More

Jupyter AI Magics Are Not ✨Magic✨

It doesn’t take ✨magic✨ to integrate ChatGPT into your Jupyter workflow. Integrating ChatGPT into your Jupyter workflow doesn’t have to be magic. New tools are…

Read More

Top 5 Takeaways from the American Chemical Society (ACS) 2023 Fall Meeting: R&D Data, Generative AI and More

By Mike Heiber, Ph.D., Materials Informatics Manager Enthought, Materials Science Solutions The American Chemical Society (ACS) is a premier scientific organization with members all over…

Read More

Real Scientists Make Their Own Tools

There’s a long history of scientists who built new tools to enable their discoveries. Tycho Brahe built a quadrant that allowed him to observe the…

Read More

How IT Contributes to Successful Science

With the increasing importance of AI and machine learning in science and engineering, it is critical that the leadership of R&D and IT groups at...

Read More

From Data to Discovery: Exploring the Potential of Generative Models in Materials Informatics Solutions

Generative models can be used in many more areas than just language generation, with one particularly promising area: molecule generation for chemical product development.

Read More

7 Pro-Tips for Scientists: Using LLMs to Write Code

Scientists gain superpowers when they learn to program. Programming makes answering whole classes of questions easy and new classes of questions become possible to answer….

Read More