working with 3-D Numpy array from PYTHON in MATLAB
조회 수: 4 (최근 30일)
이전 댓글 표시
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!