Filter löschen
Filter löschen

working with 3-D Numpy array from PYTHON in MATLAB

3 Ansichten (letzte 30 Tage)
Telema Harry
Telema Harry am 6 Okt. 2021
Kommentiert: Telema Harry am 7 Okt. 2021
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.

Antworten (0)

Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by