Skip to main content

A module to allow Python to call functions from a compiled Matlab archive

Project description

libpymcr

libpymcr is a Python module for loading a compiled Matlab ctf archive and running functions within it in Python.

Whilst there is an official Mathworks binding for Python, libpymcr provides a few benefits over the official package:

  • It is compatible with versions of Python not supported by Matlab (e.g. 3.10, 3.11, 3.12). Moreover, the supported Python versions are not locked to the Matlab versions, unlike with the official packages.
  • When converting data between Matlab and Python it avoids data copies where ever possible by wrapping the underlying arrays in the target type (numpy or Matlab mxArray). In the official bindings, a data copy is required when converting data from Python to Matlab (inputs to functions).
  • It provides a simpler syntax, and if you include the provided call.m and call_python.mex files in your compiled package, you will also be able to access Matlab objects transparently in Python, and pass Python callables to Matlab to evaluate (e.g. in a fitting routine).

Getting started

You can install the package using:

pip install libpymcr

You must create a compiled Matlab archive (ctf file) of your program using the Matlab Compiler SDK toolbox, using the mcc command:

mcc -W CTF:your_program_name -U mfile1 mfile2 mfile3

Then in Python, you can load this and call the Matlab functions with:

import libpymcr
m = libpymcr.Matlab('your_program_name.ctf')
m.mfile1()

The functions, mfile1, mfile2 etc. are exposed to Python can can be called as methods of the Matlab() object.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

libpymcr-0.1.8-cp311-cp311-win_amd64.whl (208.5 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

libpymcr-0.1.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (262.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

libpymcr-0.1.8-cp311-cp311-macosx_10_15_x86_64.whl (216.3 kB view hashes)

Uploaded CPython 3.11 macOS 10.15+ x86-64

libpymcr-0.1.8-cp310-cp310-win_amd64.whl (208.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

libpymcr-0.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (263.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

libpymcr-0.1.8-cp310-cp310-macosx_10_15_x86_64.whl (216.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

libpymcr-0.1.8-cp39-cp39-win_amd64.whl (208.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

libpymcr-0.1.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (263.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

libpymcr-0.1.8-cp39-cp39-macosx_10_15_x86_64.whl (216.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

libpymcr-0.1.8-cp38-cp38-win_amd64.whl (208.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

libpymcr-0.1.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (263.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

libpymcr-0.1.8-cp38-cp38-macosx_10_15_x86_64.whl (216.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

libpymcr-0.1.8-cp37-cp37m-win_amd64.whl (208.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

libpymcr-0.1.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

libpymcr-0.1.8-cp37-cp37m-macosx_10_15_x86_64.whl (215.1 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page