Skip to content

Commit 1982529

Browse files
author
Dakota Junkman
committed
initial move of files into repo
1 parent 326ea5d commit 1982529

17 files changed

+1496
-1
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__
2+
build
3+
*.egg-info
4+
dist
5+
matlabengine-*
6+
matlabengine-test*

LICENSE.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2022, The MathWorks, Inc.
2+
All rights reserved.
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
6+
3. In all cases, the software is, and all modifications and derivatives of the software shall be, licensed to you solely for use in conjunction with MathWorks products and service offerings.
7+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# MATLAB Engine API for Python
2+
3+
The MATLAB® Engine API for Python® provides a package to integrate MATLAB functionality directly with a Python application, creating an interface to call your MATLAB functions from Python code.
4+
5+
---
6+
## Requirements
7+
### Required MathWorks Products
8+
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
9+
* MATLAB release R2022b
10+
11+
### Required 3rd Party Products
12+
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
13+
* Python 3.8, 3.9, or 3.10
14+
* Supported Python versions by MATLAB release can be found [here](https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/python-compatibility.pdf).
15+
16+
---
17+
18+
## Install
19+
20+
### Windows
21+
MATLAB Engine for Python can be installed directly from the Python Package Index.
22+
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
23+
```bash
24+
$ python -m pip install matlabengine==9.13
25+
```
26+
27+
28+
29+
### Linux&reg;
30+
Prior to installation, check the default install location of MATLAB by calling ```matlabroot``` in a MATLAB Command Window. By default, Linux installs MATLAB at:<br>
31+
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
32+
```/usr/local/MATLAB/R2022b```
33+
34+
When MATLAB is not installed in the default location, the bin/*architecture* directory within the MATLAB root directory must be added to an environment variable. The path can be added to the environment variable within the shell startup configuration file (for example, .bashrc for bash shell or .tcshrc for tcsh).
35+
36+
```bash
37+
# in .bashrc
38+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:matlabroot/bin/glnxa64
39+
```
40+
41+
```bash
42+
# in .tcshrc
43+
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:matlabroot/bin/glnxa64
44+
```
45+
46+
MATLAB Engine for Python can be installed directly from the Python Package Index.
47+
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
48+
```bash
49+
$ python -m pip install matlabengine==9.13
50+
```
51+
52+
### macOS
53+
Prior to installation, check the default install location of MATLAB by calling ```matlabroot``` in a MATLAB Command Window. By default, macOS installs MATLAB at:<br>
54+
55+
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
56+
```/Applications/MATLAB_R2022b.app```
57+
58+
When MATLAB is not installed in the default location, the bin/*architecture* directory within the MATLAB root directory must be added to an environment variable. The path can be added to the environment variable within the shell startup configuration file (for example, .bashrc for bash shell or .tcshrc for tcsh).
59+
60+
```bash
61+
# in .bashrc
62+
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:matlabroot/bin/maci64
63+
```
64+
65+
```bash
66+
# in .tcshrc
67+
setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:matlabroot/bin/maci64
68+
```
69+
70+
MATLAB Engine for Python can be installed directly from the Python Package Index.
71+
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
72+
```bash
73+
$ python -m pip install matlabengine==9.13
74+
```
75+
76+
---
77+
78+
## Getting Started
79+
* Start Python.
80+
* Import the ```matlab.engine``` package into the Python session.
81+
* Start a new MATLAB process by calling ```start_matlab```. The ```start_matlab``` function returns a Python object which enables you to pass data and call functions executed by MATLAB.
82+
83+
```python
84+
>>> import matlab.engine
85+
>>> eng = matlab.engine.start_matlab()
86+
>>> eng.sqrt(4.0)
87+
2.0
88+
```
89+
90+
* Call either the ```exit``` or ```quit``` function to stop the engine. Exiting Python with an engine running stops the engine and its MATLAB processes.
91+
92+
```python
93+
>>> eng.quit()
94+
```
95+
96+
See [Start and Stop MATLAB Engine for Python](https://www.mathworks.com/help/matlab/matlab_external/start-the-matlab-engine-for-python.html) for advanced startup examples.
97+
98+
---
99+
100+
## Examples
101+
You can call any MATLAB function directly and return the results to Python.
102+
```python
103+
>>> eng.plus(2, 3)
104+
5
105+
>>> eng.isprime(37)
106+
True
107+
>>> eng.gcd(100.0, 80.0, nargout=3)
108+
(20.0, 1.0, -1.0)
109+
```
110+
See [Call MATLAB Functions from Python](https://www.mathworks.com/help/matlab/matlab_external/call-matlab-functions-from-python.html) for more usage examples.
111+
112+
---
113+
114+
## Limitations
115+
Limitations of the MATLAB Engine API for Python can be found [here](https://www.mathworks.com/help/matlab/matlab_external/limitations-to-the-matlab-engine-for-python.html).
116+
117+
---
118+
119+
## Troubleshooting
120+
See [Troubleshoot MATLAB Errors in Python](https://www.mathworks.com/help/matlab/matlab_external/troubleshoot-matlab-errors-in-python.html) for troubleshooting assistance.
121+
122+
---
123+
124+
## License
125+
This software is licensed under the MathWorks XLSA License, which is available in the LICENSE.txt file within this repository.
126+
127+
---
128+
129+
## Support
130+
Technical issues or enhancement requests can be submitted [here](https://github.com/mathworks/matlab-engine-for-python/issues).
131+
132+
---
133+
134+
Copyright &copy; 2022 MathWorks, Inc. All rights reserved.
135+
136+
Linux&reg; is the registered trademark of Linus Torvalds in the U.S. and other countries.
137+
138+
Mac OS is a trademark of Apple Inc., registered in the U.S. and other countries.
139+
140+
"Python" and the Python logos are trademarks or registered trademarks of the Python Software Foundation, used by MathWorks with permission from the Foundation.

SECURITY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Reporting Security Vulnerabilities
2+
3+
If you believe you have discovered a security vulnerability, please report it to
4+
[[email protected]](mailto:[email protected]). Please see
5+
[MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html)
6+
for additional information.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools >= 42", "wheel"]
3+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)