jupyter notebook using matlab
The following method assumes that the matlab program is already installed, if not, please install it and then perform the following steps
Installing python
Go to the MATLAB\extern\engines\python folder, you can see the file, right-click to run using python
Or directly from the cmd command line, cd into the corresponding folder, type
python install
Note that if you have conda installed, in which environment you want to use jupyter notebook, activate the corresponding environment first, and then repeat the above steps (after testing matlab engine does not seem to be interoperable in different environments)
2. Install matlab_kernel
Go to cmd and type
pip install matlab_kernel
Similarly, if you want to use jupyter notebook in any environment, activate the corresponding environment and use the conda command to install matlab_kernel.
3. Run jupyter notebook in matlab
Run jupyter notebook and you can use matlab.
Similarly, if you are using Conda's self-contained environment, activate the corresponding environment and go to jupyter notebook.
jupyter notebook added to matlab kernel
1. Under the matlab installation file, find the following interface
2. open anaconda prompt, in this cd to the above picture open setup. py path (or directly right-click to open with python, I used after no use, someone can)
If matlab is located on disk d, remember to start by typing d:.
3. Type python install
4. install matlab kernel for jupyter
Type pip/conda install matlab_kernel (use either pip or conda, I use pip)
python -m matlab_kernel install
Question: If you encounter
PackagesNotFoundError: The following packages are not available from current channels:
- matlab_kernel
Code like this
- Try conda install -c conda-forge matlab_kernel
- When running python -m matlab_kernel install, if it indicates that permissions are defined, do as it suggests, adding --user at the end.
Supplementary: 5. If you need to add matlab engine to the
Inside the cmd, type: python
import engine = .start_matlab() (nargout=0)
6. Finish the above, you can open the jupyter
Reopen a cmd and type jupyter notebook in the cmd to open the
Just use the first Matlab.
summarize
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.