How to import a 3D Python numpy array into Matlab ?

63 ビュー (過去 30 日間)
Dimitri Lepoutre
Dimitri Lepoutre 2019 年 5 月 15 日
回答済み: abraham rodriguez 2021 年 9 月 18 日
Hello,
I am new to MATLAB as it appears as though Python does not allow to represent four-dimensional data as shown here: https://fr.mathworks.com/help/matlab/visualize/visualizing-four-dimensional-data.html
I have a (10,20,20) numpy array on Python (each value T[x,y,z] is the temperature value of a volume.
(Basically slices of data that look like this)
How can I:
  • Export this array to a MATLAB compatible format
  • Import it into MATLAB
  • And visualize it as shown below:
Thank you in advance for your answer,
  1 件のコメント
Gabriel Beckers
Gabriel Beckers 2021 年 7 月 19 日
The python library Darr allows you to save your Python numpy arrays in a self-documenting and widely readable format, consisting of just binary and text files. When saving your array, it will include code to read that array in a variety of languages, including Matlab. So in essence, it is just one line to save your 4-d array to disk in Python, and then copy-paste the code from the README.txt to load it into Matlab.

サインインしてコメントする。

回答 (2 件)

gonzalo Mier
gonzalo Mier 2019 年 5 月 15 日

abraham rodriguez
abraham rodriguez 2021 年 9 月 18 日
In latest R2021a, you can pass a python numpy ndarray to double() and it will convert to a native matlab matrix, even when calling in console the numpy array it will suggest at the bottom "Use double function to convert to a MATLAB array"
.

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by