Hi Nina,
As an alternative to converting Python code to MATLAB, you can use Python code directly within MATLAB since MATLAB provides built-in support for calling Python functions.
Please refer to the following approach explaining how to call Python functions from MATLAB:
Ensure Python is Installed: Confirm that Python is installed on your system and that MATLAB is set up to utilize it.
Call Python Functions from MATLAB: You can directly call Python functions from MATLAB by using the py prefix. For example, if you have a Python function called my_function within a module named my_module, you can use:
result = py.my_module.my_function(arg1, arg2);
Use Python Libraries in MATLAB: You can leverage Python libraries directly in your MATLAB code. For example, to use the numpy library:
np = py.importlib.import_module('numpy');
array = np.array([1, 2, 3, 4]);
This approach allows you to take advantage of Python libraries and functionality without needing to rewrite code in MATLAB.
Kindly refer to the following MathWorks documentation on ‘Call Python from MATLAB’ discussed above: https://www.mathworks.com/help/matlab/call-python-libraries.html
I hope the solution provided above is helpful.