C2DH / journal-of-digital-history-jupyter-stack

Image for the journal of digital history
GNU Affero General Public License v3.0
1 stars 7 forks source link

Matlab in jupyter notebook #5

Open eliselavy opened 2 years ago

eliselavy commented 2 years ago

Matlab in jupyter notebook

2 solutions tested:

eliselavy commented 2 years ago

Test of the MATLAB Integration for Jupyter has been made: Project here : https://github.com/mathworks/jupyter-matlab-proxy =>Enables you to access MATLAB in a web browser from your Jupyter environment. This package currently, does not provide a kernel level integration with Jupyter. (under active development)

  1. Prerequis: having Matlab installed

⚠️ have the appropriate licence to run the MATLAB Integration for Jupyter Screenshot 2022-11-28 at 14 25 30

  1. TAKE CARE TO

For Mac user: Messages  Show Package Contents

interproces 9-1e368a51acdf.png) Screenshot 2022-11-28 at 12 00 24

Set bash_profile:

# Setting PATH forMatlab
# The original version is saved in .bash_profile.pysave
PATH="/Applications/MATLAB_R2022b.app/bin/:${PATH}"
export PATH
  1. python -m pip install jupyter-matlab-proxy

Screenshot 2022-11-28 at 14 24 20 This package currently, does not provide a kernel level integration with Jupyter. (under active development)

Screenshot 2022-11-28 at 14 40 26

eliselavy commented 2 years ago

TO TEST also: MATLAB Integration for Jupyter in a Docker Container https://github.com/mathworks-ref-arch/matlab-integration-for-jupyter/tree/main/matlab The Dockerfile in this repository builds a Docker® image based on jupyter/base-notebook which contains the jupyter-matlab-proxy package and installs MATLAB® using the MATLAB Package Manager (mpm).

The resulting Jupyter environment enables you to start MATLAB in a web browser tab from a Jupyter® notebook.

If you want to install the MATLAB Integration for Jupyter without using Docker, use the installation instructions in the repository MATLAB Integration for Jupyter instead.

eliselavy commented 2 years ago

TESTED ALSO: MATLAB kernel for Jupyter Project here : https://github.com/Calysto/matlab_kernel

Prerequis

  1. Matlab engine for Python

https://fr.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html

Install Using pip Starting with MATLAB R2022b, you can use the pip command to install the API.

One solution:

python -m pip install .


Other solution:

=> I choose the first solution

:warning: OSError: MATLAB Engine for Python supports Python version 2.7, 3.8, 3.9, and 3.10, but your version of Python is 3.7

=> upgrade if you are in same case as me

Screenshot 2022-11-28 at 16 04 55

  1. Install the matlab_kernel pip install matlab_kernel

  2. Start jupyter notebook

  3. Create notebook with the MATLAB kernel

Screenshot 2022-11-28 at 16 44 45

  1. Insert example
t = linspace(0,6*pi,100);
plot(sin(t))
grid on
hold on
plot(cos(t), 'r')

Screenshot 2022-11-28 at 16 25 40