1

I have a huge Matlab code that I want to convert to Python, my code is more than 10K lines of code, in addition, it includes some calls to other Matlab files, toolboxes, plots, and GUI figures. Therefore I'm looking for an automatic solution to this problem to help me here.

I searched on the internet and I found this package called SMOP, which is great but unfortunately, it only supports Python2.7, also it does not contain the conversion of the plots nor the GUI figures, and I'm not sure if it is able to convert the calls to the toolboxes or not. in addition, sometimes it gives me an error.

This is the best option I have found so far, but I really want a better solution because you can see how huge the code is. If anyone could help me with this problem I would really appreciate it.

1
  • 2
    I think there is no tool or function to do this Commented Dec 15, 2020 at 13:49

2 Answers 2

2

Unfortunately, no such tool exists, especially for complex things like conversion of toolboxes.

I suggest that you try to find places in your codebase where you could divide your logic into self-contained modules. Then, you can work on converting your code one module at a time. You should already start to familiarize with numpy which will serve as the replacement for the majority of your matrix math operations.

It's worth noting that converting Python 2 to 3 is relatively straightforward and there is an official tool (2to3) that can help you do this automatically. However, be careful with converters like the one you found, a quick scan of their github shows 65 outstanding issues and no updates for nearly 3 years.

Good luck with the conversion! Although it will not be as easy as you may have hoped, the switch to Python will make development much easier in the long run.

1
  • I was afraid of that, I guess I will try what you suggest (dividing my code) and will see how this is going with me. Thank you for your answer.
    – abdullatif
    Commented Dec 16, 2020 at 8:51
0

I think the short answer is that there is no such tool that will do this reliably. You can use matlab code though in python and opposite using the matlab engine API, but there are some limitations. Have a look for more details in the doc here

1
  • 1
    That is an option, but we prefer to have python code independent of MATLAB, if no solution is provided, I guess we have no other option. Thank you for your answer
    – abdullatif
    Commented Dec 16, 2020 at 8:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.