working with 3-D Numpy array from PYTHON in MATLAB

4 ビュー (過去 30 日間)
Telema Harry
Telema Harry 2021 年 10 月 6 日
コメント済み: Telema Harry 2021 年 10 月 7 日
I opened GRIB2 files as a 3-D Numpy array in python and I want to save the data in a .mat file so I can can use the data in my MATLAB model.
Assuming the 3-D Numpy array has a shape of (3, 2, 4), where the 3 is the depth, 2 is the row and 4 is the column.
I can save the data in .mat files using the command:
b = np.array([[[1,2,4,2],[3,4,6,0]],[[5,7,6,1],[7,8,0,9]], [[3,1,0,1],[1,0,5,9]]])
dict = {'B':b}
sio.savemat ('/Volumes/Converted files/test.mat',dict)
The challenge:
A 3-D array of (3,2,4) is read differently in MATLAB, it is interpreted as 3 = row, 2 = column and 4 = depth.
In MATLAB, the data should have the following form (2,4,3)
My question:
Please, how will I manipulate the data in MATLAB such that it will have same meaning ?
>> b(:,:,3) = [3,1,0,1; 1,0,5,9]
b(:,:,1) =
1 2 4 2
3 4 6 0
b(:,:,2) =
5 7 6 1
7 8 0 9
b(:,:,3) =
3 1 0 1
1 0 5 9
Thank you.
  2 件のコメント
Telema Harry
Telema Harry 2021 年 10 月 7 日
Thank you. This solved the problem

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

回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by